How to Continue the Test step execution , even on failure of a Test step in Cucumber

Hi Guys ,
Am using Cucumber Framework with selenium. Currently if one test step fails  , all the other steps are getting skipped.How to Continue the Test step execution , even on failure of a Test step.

sudheer Default Asked on April 26, 2015 in Selenium WebDriver.
Add Comment
5 Answer(s)

Sudheer,

The whole point of assertion is to assert something, if not stop the further execution. We usually use assertions in situations where we know that if a particular thing fails there is no point in executing the test further.

I think what you are looking for is a simple Verify. Try to check for the condition and print a message in the report. Instead of applying assertion.

Virender

Virender Singh Professor Answered on April 27, 2015.
Add Comment

Are you using assertion in your test step? if there is an assertion in the test step or an exception, that test will cause the whole execution of the test to stop.

Try putting a try catch or not throwing an Assertion in that step and your execution will not stop.

Virender

Virender Singh Professor Answered on April 27, 2015.
Add Comment

Yes . I am using Assertion since , i should see the failure of the Step & screenshot in the Test Report Generated.

sudheer Default Answered on April 27, 2015.
Add Comment

use Verify or a custom check and log structure instead of assert. Assert is only used when  you want to stop the execution of the test when it fails.  In short at absolutely necessary conditions, without which there is no point in executing the test further.

Virender

Virender Singh Professor Answered on April 28, 2015.
Add Comment

Hi Virender ,
Thanks a lot for the response.
I have removed Assertions , instead kept a basic condition check & adding the message to the report in case of condition fail. Which is making my execution continued.

sudheer Default Answered on May 5, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.