O'Reilly logo

Jenkins: The Definitive Guide by John Ferguson Smart

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Automating Your Unit and Integration Tests

Automating Your Tests with Maven

Maven is a popular open source build tool of the Java world, that makes use of practices such as declarative dependencies, standard directories and build life cycles, and convention over configuration to encourage clean, maintainable, high level build scripts. Test automation is strongly supported in Maven. Maven projects use a standard directory structure: it will automatically look for unit tests in a directory called (by default) src/test/java. There is little else to configure: just add a dependency to the test framework (or frameworks) your tests are using, and Maven will automatically look for and execute the JUnit, TestNG, or even Plain Old Java Objects (POJO) tests contained in this directory structure.

In Maven, you run your unit tests by invoking the test life cycle phase, as shown here:

$ mvn test [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Tweeter domain model [INFO] task-segment: [test] [INFO] ------------------------------------------------------------------------ ... ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.wakaleo.training.tweeter.domain.TagTest Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.093 sec Running com.wakaleo.training.tweeter.domain.TweeterTest Tests run: 3, Failures: 0, Errors: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required