Thank you very much for your great advices on using Assertions. I want to
of test data like blank data, invalid data, special characters.
selenium driver is launched in @Before method. That would eat lot of time
in execution only, but with manual testing if would hardly take seconds. To
field level validation in my one step , for eg in @Then. At the same time.
I record all my failures and successful assertions in one single run.
Post by aslak hellesoyPost by Eajaz AliPost by Paul RaynerPost by Eajaz AliHi Team,
I am using cucumber-jvm framework for my automation tests. I want to
implement continuation of my step even after there is an assertion
failure.
Post by Paul RaynerPost by Eajaz Ali@Given("^I perform validation$")
public I_perform_validation(){
//assertion1 -> fail
//assertion2 -> pass
//assertion3 -> pass
}
If assertion1 fails, I still want to continue to assertion2 and assertion3.
Can someone please help. This will be really helpful, as I don't want
to
Post by Paul Rayner'Given' is for setting up context, the state of the system under test,
not
Post by Paul Raynerfor making assertions. That is what 'Then' is for.
I disagree with this statement. I find it very useful to have
assertions in Given steps. The purpose is to check that the data setup
has been done correctly.
When I explain Given-When-Then I often compare to a theatrical act.
Before the act starts, the stage workers work behind the curtains to set
up the *stage*. They place furniture in the right locations, adjust the
lighting to give the impression of dusk. The actors walk onto the stage.
Mrs Alving is in the dining room. Oswald is in the living room. The
curtains unfold, and the stage is set.
This is the Given. There is nothing to verify, just setting up the scene.
We're only describing what's happened in an imaginary recent past.
Now the act unfolds. The actors talk and move. At one point something
important *happens*.
This is the When.
Later, the act has finished. The curtains are drawn again. The spectators
are sitting in their seats, thinking about everything that unraveled before
their eyes. What happened? What was essential? What was the *outcome*?
This is the Then.
----
Now, back to Cucumber. Sometimes we're dealing with a system where test
automation is an after-thought. We can't easily set up the stage the way we
want, because we're not in control over the venue, the decorations or even
the actors. We have to deal with a system that is in a state we can't
control. So we have to improvise. We can go on with the act if certain
elements are present. Are we indoors? Check. Is there a table? Check. Do we
have a woman and a man? Check.
I think this is what you're describing Paolo. I agree that in such cases,
Given steps can make assertions. It's important to emphasise that this is a
different kind of game though. You only do that when things are
unpredictable. If we can, we want to make things predictable. We want to
control (or stub out) external dependencies. When we can do that, we don't
need assertions in our Given steps.
The same goes for When steps. You *can* use assertions here, but you
shouldn't have to.
The only place where you absolutely *should* use assertions is Then steps.
A final word of advice: Never trust a test you haven't seen fail. You want
to make sure your steps will fail with an error when the system doesn't
behave as expected. If you catch exceptions or continue after a step has
failed, your tests are useless, because they *cannot* fail.
It's like taking the batteries out of your smoke detector.
Aslak
Post by Eajaz AliSometimes I even use assertions in When steps
for sanity checks (e.g. to verify that the server didn't return an
internal server error). In both cases of course the assertions do not
verify business rules, as that must happen in Then steps.
Post by Paul RaynerThe 'Then' (plus any subsequent 'And' statements) is where the
assertion is
Post by Paul Raynermade. Hence, "Then".
It's generally considered very poor practice to continue when an
assertion
Post by Paul Raynerfails, since the whole point of making such an assertion in BDD is to
verify
Post by Paul Raynerthat some piece of important functionality is currently missing and
needs to
Post by Paul Raynerbe implemented. Why would you want to continue?
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google
Groups
Post by Paul Rayner"Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Paul RaynerFor more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the
Google Groups "Cukes" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/cukes/OTUjEupNjYk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.