Skip to content

Running your tests

jose.fernandez edited this page Aug 11, 2021 · 10 revisions

Since Gingerspec is based on TestNG and cucumber, Gingerspec tests are executed as any other regular testNG or cucumber based project. Gingerspec also makes use of the maven-failsafe-plugin

The maven-failsafe-plugin introduces four phases for running integration tests:

  • pre-integration-test for setting up the integration test environment.

  • integration-test for running the integration tests.

  • post-integration-test for tearing down the integration test environment.

  • verify for checking the results of the integration tests.

So, for running the ALL integration tests, you can simply execute

mvn verify

Rather than trying to invoke the integration-test phase directly, as otherwise the post-integration-test phase will not be executed. (mvn verify is also shorter to type too ;) )

When you execute "mvn verify", you will be executing ALL integration tests. If you remember in the Structure of a Gingerspec-based project, section "B", the runner classes that contain the suffix "IT" at the end are considered integration tests classes, so, Gingerspec will execute all the features listed in those classes.

If you would like to execute just one particular runner class, you can do so by indicating the name of the class like this:

mvn verify -Dit.test=com.privalia.mytestproject.mypackage.CucumberRestIT

In windows, you may need to use quotes ('') when passing variables via maven!

mvn verify -D'it.test'='com.privalia.mytestproject.mypackage.CucumberRestIT'

This will execute the features listed in only that particular runner class

You can, of course, run your tests and specify tags to be executed. This allows filtering the execution of scenarios to the ones that contain that particular tag (check more info here)

For example, let's execute all the scenarios that contain the @web tag:

mvn verify -Dcucumber.filter.tags="@web"

Or all scenarios with @web tag and ignore the ones with @notReady tag:

mvn verify -Dcucumber.filter.tags="@web and not @notReady"

You can even run an specific feature file:

mvn verify -Dcucumber.features=src/test/resources/features/my_feature.feature

If you want to check whether all feature file steps have corresponding step definitions, you can perform a dry run like this

mvn verify -Dcucumber.execution.dry-run=true

See more info in the cucumber official documentation here

You can also pass maven variables when running your tests. You can use these variables in your gherkin scenarios or use them to configure intenal aspects of GingerSpec behaviour, like changing the default browser to be used during your selenium tests or setting up a selenium grid