Selenium Cucumber Java BDD Framework 8 - Tags | Step by Step

Publicado el: 18 junio 2020
en el canal de: Automation Step by Step
74,988
827

FREE tutorials - https://automationstepbystep.com/
QUIZ - https://forms.gle/UJN8HYVAfGtNFUMh6
Note: For some users removing curly brackets worked.
Today we will learn:
1 - What are Tags
2 - How to use Tags (Demo)
3 - Useful Tips

What are Tags in Cucumber
Features and Scenarios can be marked with Tags
Tags use @ symbol with some text e.g. @SmokeTest
In the test runner we can run specific tags
A feature or scenario can have multiple tags

@smoke @regression @important
Feature: Verify login

Can run with single OR multiple Tags
Can run with a combination of tags or using AND, OR conditions
Can skip scenarios having specific Tag

Step 1 - Create a new or use an existing Feature File
Step 2 - Mark the feature and scenarios with Tags : @TagName
Step 3 - Create new or use an existing TestRunner class
Step 4 - Add the tags in CucumberOptions section

@RunWith(Cucumber.class)
@CucumberOptions(
features="src/test/resources/features",
glue= {"Steps"},
tags = {"@SmokeTest"}
)
public class TestRunner {
}

Step 5 - Run test runner class with different combination of tags

Single tag - tags = {"@smoke"}

Multiple tags
Tags with AND OR conditions
tags = {"@smoke or @regression"}
tags = {"@smoke and @regression"}
tags = {"@smoke and not @regression"}

Skip or Ignore Tags
tags = {"(@smoke or @regression) and not @important"}

Useful Tips - General
Tags can be placed above the following Gherkin elements:
Feature
Scenario
Scenario Outline
Examples
It is not possible to place tags above Background or steps (Given, When, Then, And and But)

Useful Tips - Tags Inheritance
Tags are inherited by child elements.
Tags that are placed above a Feature will be inherited by Scenario, Scenario Outline, or Examples.
Tags that are placed above a Scenario Outline will be inherited by Examples

Useful Tips - Execution with Tags
You can create and keep ready multiple TestRunner classes with different combination of Tags
OR
Create commands with tags combination as required to be run from the command line
mvn test -Dcucumber.filter.tags="@smoke and @fast"

References - https://cucumber.io/docs/cucumber/api...

Join Automation Step By Step family and get access to perks: https://www.youtube.com/automationste...

Hi, I am Raghav and today we will learn -

Hit Like and. Subscribe button, if you like this video. It gives me great motivation.

You can support my mission for education by sharing this knowledge and helping as many people as you can

If my work has helped you, consider helping https://animalaidunlimited.org/ or any animal welfare group near you, in any way you can.

_______ ONLINE COURSES TO LEARN _______
https://automationstepbystep.com/onli...


En esta página del sitio puede ver el video en línea Selenium Cucumber Java BDD Framework 8 - Tags | Step by Step de Duración hora minuto segunda en buena calidad , que subió el usuario Automation Step by Step 18 junio 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 74,988 veces y le gustó 827 a los espectadores. Disfruta viendo!