The Maven team believes that unit testing can be a very useful tool in improving the quality of software, in particular to enforce a loosely coupled design and to give the ability to regression test the code over time. For this reason, unit test support (provided by JUnit in Java) is included out of the box, and an integral part of the build process.
To configure your test suite, add the unitTest
element to the project descriptor.
By default, the tests are run whenever you package your artifact to ensure they continue to pass. They can also
be run explicitly using the command: maven test:test
.
If you need to skip tests temporarily for speed, you can use the maven.test.skip
property:
maven -Dmaven.test.skip=true jar
This is not generally recommended, however - your tests should remain fast enough that running them regularly does not have a negative impact.
There are other test goals to run individual tests or a subset of tests, as well different configuration options. For more information, see the test plugin reference.