How to Fail a step in cucumber?

75 views
Skip to first unread message

Ravindra Lb

unread,
Mar 22, 2018, 6:51:17 AM3/22/18
to Cukes

Hello everyone,

I'm fairly new to Cucumber implementation for Selenium. I am trying to find a solution to mark a cucumber step as "failed" so it shows up on the cucumber extent report plugin that i am using.

Currently, the report fails only on assertion (junit) errors/exceptions and skips the rest of the steps under a feature scenario.


Please suggest. Thanks!

Andrew Premdas

unread,
Mar 22, 2018, 6:56:28 AM3/22/18
to cu...@googlegroups.com
A cucumber scenario should fail for one of the following reasons

1. An exception, or error was thrown
2. An assertion failed

If you want to fail a scenario, throw an exception. But why would you want to do this if your scenario is working?

All best

Andrew

--
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 email to cukes+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
------------------------
Andrew Premdas

Koen Prins

unread,
Mar 25, 2018, 2:10:46 AM3/25/18
to cu...@googlegroups.com
Andrew,

He asks how to fail a step and, I assume, for the scenario to continue.
@Ravindra, there is no good reason to continue a scenario if a step failed. If you want to assert each and every step in a scenarion, write seperate scenario's for each step.
Cucumber approaches a scenario as a whole, all steps are part of the test so if one fails, the entire test fails.
Hope this helps.

Gr,
Koen
Reply all
Reply to author
Forward
0 new messages