Run a single test method with maven
To run a single test method in Maven, you need to provide the command as:
mvn test -Dtest=TestCircle#xyz test
where TestCircle
is the test class name and xyz
is the test method.
Wild card characters also work; both in the method name and class name.
If you're testing in a multi-module project, specify the module that the test is in with -pl <module-name>
.
For integration tests use it.test=...
option instead of test=...
:
mvn -pl <module-name> -Dit.test=TestCircle#xyz integration-test
How to run a specific maven test class from the terminal?
mvn -Dtest=TestCircle test
see https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
Can't run single test method with maven
The syntax above is only supported for Maven Surefire version 2.7.3+
Make sure you're using the correct version of the plugin.
Maven surefire plugin DOES NOT run single test, out of many
The surefire plugin (by default) will run only tests with the following name syntax ...
"**/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test".
"**/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test".
"**/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests".
"**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".
More details can be found here
Maven run command for specific test suite
This cannot be done in the way you describe it.
test
is a phase and as such, part of the standard lifecycle. Calling mvn test
does not only run tests, but executes the phases before test
as well.
The standard lifecycle also offers phases for integration tests, esp. integration-test
. Integration tests are usually put into src/test
as well and distinguished by a naming convention. But beware: Calling mvn integration-test
will call all previous phases (including test
, compile
etc.) as well.
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
How to run single test from test class scala?
and we have another command for running one test from testing class and ignoring another ones?
That should be possible, but using ScalaTest with maven, or ScalaTest with sbt.
Related Topics
How to Setsize of Image Using Rescaleop
Is There a Fixed Sized Queue Which Removes Excessive Elements
Installed Java 7 on MAC Os X But Terminal Is Still Using Version 6
Leiningen - How to Add Dependencies for Local Jars
Testing Private Method Using Mockito
Spark Read File from S3 Using Sc.Textfile ("S3N://...)
Varargs and the '...' Argument
Jprogressbar Isn't Progressing
Cast Double to Integer in Java
How to Remove a Cookie in a Java Servlet
Best Way to Format Multiple 'Or' Conditions in an If Statement
How to Access Parameters in a Restful Post Method