1. Roberto Lo Giacco
  2. atdd

Wiki

Clone wiki

atdd / Home

Please note that the Maven verify phase is included in the install phase so it's safe to replace verify with install everywhere in the following usage examples.

Unit test coverage reports can be found in target/site/coverage and integration tests coverage in target/site/coverage-it.

Configuration

Cucumber feature files are by default located in src/test/features as specified in the cucumber.features.dir POM property.

The servlet container used in the example is Tomcat 7.0.20 and it supposed to be downloadable from http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.30/bin/apache-tomcat-7.0.30.zip as specified in the zipUrlInstaller/url POM tag: refer to http://cargo.codehaus.org/Maven2+plugin for information on how to use a different servlet container or an installed location.

The WebDriver implementation used by default for the integration tests is specified within the src/test/resources/cucumber.xml file but it can easily be overriden by providing the fully qualified class name as value to the selenium.driver JVM argument:

-Dselenium.driver=org.openqa.selenium.ie.InternetExplorerDriver 

All the remaining defaults are located in the JUnitWrapper class as Cucumber.Options annotation attributes.

Usage examples

> mvn verify -DskipITs=true

Builds the application running unit tests and calculating unit test coverage.

> mvn package cargo:run

Builds the application and starts it in the defined container. Maven will wait for user interaction: useful for exploratory testing and for manually running specific feature subsets.

> mvn verify

Builds the application and runs the automation tests collecting coverage on unit and automation tests.

> mvn integration-test -Dfeature=some/thing.feature

Builds the application, starts the container, runs the scenarios in src/test/features/some/thing.feature, closes the container. Code coverage collected for unit and automation test.

> mvn verify -Dtags=@sprint-1

Builds the application, starts the container, runs all the automation tests tagged with @sprint-1, closes the container. Code coverage collected for unit and automation test.

> mvn failsafe:integration-test -Dtags=~@sprint-1

Builds the application and runs all the automation tests not tagged with @sprint-1 (the container is not started/closed). No coverage collected. To be used in conjunction with mvn cargo:run.

> mvn failsafe:integration-test  -Dfeature=some/thing.feature -Dtags=@sprint-1

Builds the application and runs all the scenarios in src/test/features/some/thing.feature tagged with @sprint-1 (the container is not started/closed). No coverage collected. To use in conjunction with mvn cargo:run.

IDE Integration

If you want to use the JUnitWrapper within your IDE to run your automation tests it is important you specify the following JVM argument (consider the value as an example):

-Dwebapp.base.url=http://localhost:8080/atdd

Optionally you can switch to a different browser by specifying selenium.driver JVM argument.

-Dselenium.driver=org.openqa.selenium.ie.InternetExplorerDriver 

Updated