Stop execution and Dry run in behave BDD

Tutorial​​ 20​​ ​​ ​​ Stop execution and Dry run​​ in behave BDD

Welcome to the 20th article in Behave BDD series!

What you will Learn :

  • Stop execution on first failure

  • Run without running --dry-run​​ ​​ 

How to​​ Stop execution on first failure

Let us suppose you want to execute a set of feature files but want to make sure that the test execution should terminate on first failure.​​ 

Before we look into the actual topic, let us first execute the ‘behave’ command that will execute all the feature files​​ 

​​ 

So see below


If you notice above, we had 2 failures in total.

Let us execute ‘behave --help’ command.

Notice below that we have --stop command​​ 


Let us execute​​ behave --stop​​ command​​ ​​ 

Notice above that we had only 1 failure instead of 2 that we saw earlier. What this means is that the further execution stopped after 1st​​ failure.​​ 

Run without running --dry-run

Let us suppose we have quite a huge test suite, comprising of let’s say 100 feature files. Now, before we kick off the actual test execution, we might want to know if there are any syntax errors, if there are steps that are un-defined, check if some imports are missing and so on.​​ 

So, --dry-run will run the test suite but the actual tests execution will not happen. So the execution would be very fast.

So --dry-run​​ is​​ very​​ useful for identifying​​ any​​ issues​​ upfront. Once we fix all the issues, we can then kick off the actual test execution.

See​​ above, there is a --dry-run parameter that we can execute.

Let us execute​​ behave --no-capture --dry-run


Notice above that we see ‘9 untested’ scenarios. This means that none of the scenarios got executed.

Let us comment out a step in any of the step definition files, see below

Save

Let us re-execute​​ behave --no-capture --dry-run

Notice above that we have got a suggestion to add the missing steps.

So this is how we can use dry-run command to clean up some of the early issue.

With this, we have finished our core behave BDD tutorials!

Thank you​​ for reading!

Share On

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on tumblr
Share on email

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Lifetime Membership Club

LIFETIME MEMBERSHIP BIG SALE - ALL LIVE COURES JUST - 7000 RS/ 99 USD
Attend All Live courses in just 7000 rs / $99 - offer ends 10th Nov 2024