TestNG is a great test framework. At most of the time is used for unit test. While it can also be used for integration test.
- is a software testing method
- test a piece of code
- methods as interfaces
- does not install the software being developed
- mocks can be used to isolate external dependencies
- is a software testing method
- test the software. The software is called SUT (System Under Test)
- the whole software is a black box
- the software usually need be installed
- mocks can be used to isolate external dependencies
In this case, the project is a test project. All code are used for testing. While we can split the testing into two parts.
- integration test
- unit test the integration test
Some functions will be needed to support intetration test. The following parts are most common functions needed for integration test.
- interface module which connect to the SUT (System Under Test), REST, WebService, SSH
- authentication in order to connect to the SUT.
- data collection
All unit tests are located at directory src/test.
Surefire plugin has great support for unit test.
Default tesgng pattern for file are
- **/IT.java
- ***/*IT.java
Execute unit test with following command
mvn test
In the example the following two test cases will be run
class TestUnit1
class TestUnit2
The report will be located at
${basedir}/target/surefire-reports
All integration test are located at directory src/test
Failsafe plugin has great support for integration test.
Default failsafe pattern for file are
- **/IT.java
- ***/*IT.java
- ***/*ITCase.java
Execute integration test with following command.
mvn verify
Execute only integration test by ignore unit test with following command.
mvn verify -Dskip.surefire.tests
In the example the following two test cases will be run
class TestUnit1
class TestUnit2
The report will be located at
${basedir}/target/failsafe-reports
Default failsafe pattern configured in this example is
- **/ITSmoke.java
Execute integration test with following command.
mvn verify -P smoke
Execute only integration test by ignore unit test with following command.
mvn verify -P smoke -Dskip.surefire.tests
Default failsafe pattern configured in this example is
- **/ITNightly.java
Execute integration test with following command.
mvn verify -P nightly
Execute only integration test by ignore unit test with following command.
mvn verify -P nightly -Dskip.surefire.tests
Default failsafe pattern configured in this example is
- **/ITWeekly.java
Execute integration test with following command.
mvn verify -P weekly
Execute only integration test by ignore unit test with following command.
mvn verify -P weekly -Dskip.surefire.tests