O'Reilly logo

Apache Maven Cookbook by Raghuram Bharathan

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

Using the Maven Surefire plugin to run unit tests

A best practice of software development is writing automated unit tests for the code that you develop. Let us now see how to run these tests.

The plugin that does this job is the Maven Surefire plugin.

How to do it...

To run unit tests using the Maven Surefire plugin, perform the following steps:

  1. Open the command prompt.
  2. Run the following command on one of our sample projects:
    mvn test
    
  3. Observe the various steps that get executed:
    [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ simple-project ---
    [INFO] Surefire report directory: C:\projects\apache-maven-cookbook\simple-project\target\surefire-reports
    -------------------------------------------------------
     T E S T S
    ------------------------------------------------------- ...

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