Maven Single Test
Running a single test class
October 05, 2018Intro
Sometimes you want to run a single test class or a single test from a test class. Here is how to accomplish that.
Run single test class
Multimodule
mvn test -Dtest=MyTestClass -DfailIfNoTests=false
- in a multi-module product, add
-DfailIfNoTests=falseto ignore if there are no tests to run against that module. Though the documented behavior defaults to “false”, set it anyway. Different versions of maven surefire may have different defaults.
Single Module
- Running against actual module where the test resides
mvn test -Dtest=MyTestClass
Run a single test
mvn test -Dtest=MyTestClass#testSomething -DfailIfNoTests=false
