Chapter 10. Running JUnit tests from Maven2

 

The conventional view serves to protect us from the painful job of thinking.

John Kenneth Galbraith

This chapter covers

  • Introduction to Maven
  • Dependency management the Maven way
  • Maven Surefire plug-in
  • Maven Surefire Report plug-in

In this chapter we discuss and reveal another common build system tool called Maven. We show you how Maven differs from Ant. We also present a brief introduction to this build system, which will be useful if you’re new to it or need a way to start your tests continuously.

People sometimes come to Maven thinking that it will be something like Ant. Once they discover that it’s totally different, they get frustrated. Don’t worry; you’re not alone. This is why we spend the first few pages of this chapter explaining what’s most essential in order to understand Maven: how it’s different from Ant. After that, we present some real-world examples of compiling your test cases and running them as well as producing fancy reports.

By the end of this chapter, you’ll know how to set up your environment on your machine to build Java projects with Maven, including managing their dependencies, executing JUnit tests, and generating JUnit reports.

10.1. Maven’s features

10.2. Setting up a Maven project

10.3. Introduction to Maven plug-ins

10.4. The bad side of Maven

10.5. Summary