Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - Get list of all tests without running them?

I have a maven project and I would like to get a list of all the test classes and their file paths, without having to execute all the tests.

After I run "mvn test", the only files that I have under target/ are

checkstyle-cachefile  checkstyle-checker.xml  checkstyle-result.xml  maven-shared-archive-resources

I want something very general, that doesn't require me to edit the pom.xml file.

like image 529
greenberet123 Avatar asked May 18 '18 18:05

greenberet123


People also ask

How do you skip the tests when running a Maven package command?

To skip running the tests for a particular project, set the skipTests property to true. You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.

What is Maven skip test?

test. skip=true to skip the entire unit test. By default, when building project, Maven will run the entire unit tests automatically. If any unit tests is failed, it will force Maven to abort the building process. In real life, you may STILL need to build your project even some of the cases are failed.

What does mvn clean do?

mvn clean: Cleans the project and removes all files generated by the previous build. mvn compile: Compiles source code of the project. mvn test-compile: Compiles the test source code. mvn test: Runs tests for the project.

Which command of Maven is used to run all unit tests?

We can run our unit tests with Maven by using the command: mvn clean test. When we run this command at command prompt, we should see that the Maven Surefire Plugin runs our unit tests.


1 Answers

In my case, the test classes names were stored in

target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst

You can run mvn test-compile to create it without running the tests.

like image 143
ntg Avatar answered Sep 20 '22 07:09

ntg