Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (2.6k points)

I know you can run all the tests in a certain class using:

mvn test -Dtest=classname

But I want to run an individual method and -Dtest=classname.methodname doesn't seem to work.

1 Answer

0 votes
by (46k points)

To run a single test method in Maven, you require to provide the command as:

mvn test -Dtest=TestCircle#xyz test

Here TestCircle is the test class name and xyz is the test method.

Wild card figures also work; both in the method name and class name.

If you're inquiring in a multi-module project, define the module that the test is in with -pl <module-name>.

For integration tests you can try it.test=... option instead of test=...:

mvn -pl <module-name> -Dit.test=TestCircle#xyz integration-test

Related questions

0 votes
1 answer
asked Aug 26, 2019 in Java by Krishna (2.6k points)
0 votes
1 answer
asked Aug 8, 2019 in Java by Suresh (3.4k points)
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories