Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
739 views
in Technique[技术] by (71.8m points)

unit testing - Using Maven, how do I run specific tests?

I have thousands of unit tests in my project, and I'd like to choose one or a couple of them to run from the command line. What's the command to do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can run all the tests in a class, by passing the -Dtest=<class> flag to Maven:

mvn clean test -Dtest=xxxxTest

Since Surefire 2.8, you can also run an individual test, say a method testA within your unit tests, using the same flag:

mvn clean test -Dtest=xxxxTest#testA

More examples for running multiple tests, by name pattern or name lists, can be found in the Maven Surefire documentation > Running a Single Test.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...