Execute the script by using tag

Below is the way to execute the feature file by using tagName.

behave featureFile.feature --tags=tagName
or
behave featureFile.feature --tags tagName

If we require any data which is related to tags then type the below help command.

behave --tags-help


Execute tags by combinations

To execute scenario or feature file if it as any t1 or t2 tag ( ,)

Here comma “,” is used to execute a feature file which has a tagName of t1 or t2.

Example : If we have a feature or Scenario with the tagNames of “t1 or t2” , “only t1” , “only t2” then the below command is used to execute those types.

behave featureFile.feature --tags=t1,t2 (run scenarios tagged t1 or t2)


To execute scenario or feature file only if it as both the tags t1 and t2 tag.

Here the feature file will execute which has both the tags of t1 and t2. If any feature or scenario has only one tag(t1 or t2) then that scenario will not be executed.

behave featureFile.feature --tags=t1 --tags=t2 (run scenarios tagged both t1 and t2)


Exclude or Skip specific tag (- or ~)

Here we use symbols such as “-” or “~” after the tag name to run everything except this given tagName.

behave featureFile.feature --tags=-t3 (run everything except t3) (- or ~)