There are lots of situations when we need to run only some of our automated tests instead of the whole test suite (e.g. run only the smoke tests instead of the full regression suite; the entire suite grows and you might want to run only subsets of your tests, and so on).
How do we apply this approach?
Step 1 – Include a custom @tag in your test title (it can by anything, e.g. @smoke @regression)
In the following test file, I included @smoke tag in the title of test2 and test3.
Step 2 – Run the tests from CLI, using the -g “@smoke” flag. The test execution will include only the tests that contain this tag in their title (e.g. test2 and test3).
Considering the above example, we could use a similar approach to EXCLUDE the tests with a specific tag,
using --grep-invert "@smoke"
In the following test execution, will be executed only the tests that DO NOT contain the @smoke tag (e.g. test 1)