-
Notifications
You must be signed in to change notification settings - Fork 118
1.5. Unit and Integration Tests
If you have properly declared Pentaho parent poms as the parent of your project, you should be able to perform the actions described bellow. Any additional configuration regarding how to run tests should be provided with the project via README.md and the project wiki.
- Unit test is a highly localized test.
- It shouldn't reach outside it's own package, instead it should rely heavily on mocked objects.
- Within reason it should not rely on external resources. In some cases it's acceptable to read/write to/from the local file system, etc
- An integration is a more comprehensive test than a unit test.
- It is acceptable for it to call and use methods outside it's own package.
- It is acceptable for it to create lightweight processes as an external dependency to the test.
Our preferred stack for tests is JUnit and Mockito
- All new code must achieve and 80% code coverage as reported by wingman
- Edited code must not drop in coverage as is reported by wingman
Like suggested by the Maven's Standard Directory Layout, unit tests should live under src/test
and integration tests in src/it
within your maven module.
Check the Module Layout section for more information.
This should run all unit tests in your project (and sub-modules).
$ mvn test
To run a single test:
$ mvn test -Dtest=<<YourTest>>
If you want to remote debug a single java unit test (default port is 5005):
$ mvn test -Dtest=<<YourTest>> -Dmaven.surefire.debug
By default, integration tests should compiled and ran if the property runITs
is present. To run the integration tests for your project you should run:
$ mvn verify -DrunITs
To run a single integration test:
$ mvn verify -DrunITs -Dit.test=<<YourIT>>
To run a single integration test in debug mode (for remote debugging in an IDE) on the default port of 5005:
$ mvn verify -DrunITs -Dit.test=<<YourIT>> -Dmaven.failsafe.debug