10 Running JUnit tests from Maven 3
This chapter covers
- Creating a Maven project from the scratch
- Testing the Maven project with JUnit 5
- Using Maven plugins
- Using the Maven Surefire Plugins
The conventional view serves to protect us from the painful job of thinking.
—John Kenneth Galbraith
This chapter discusses a very common build system tool called Maven. In the previous chapters, with provided Maven projects, you needed only to look at some external dependencies, run some very simple commands, or run the tests from inside the IDE. This chapter gives you a brief introduction to the Maven build system, which will be very useful if you need a systematic way to start your tests.
Maven addresses two aspects of building software. First, it describes how software is built; then it describes the needed dependencies. Unlike earlier tools, such as Apache Ant, it uses conventions for the build procedure, and only exceptions need to be written down. It relies on an .xml file to describe its full configuration—most important here the meta-information about the software project being built, the needed dependencies on other external components, and the required plugins.
At the end of this chapter, you will know how to build Java projects with Maven, including managing their dependencies, executing JUnit tests, and generating JUnit reports.
For the basic Maven concepts and how to set it up, please have a look at Appendix A.