简体   繁体   中英

How to use Maven to test code with a non-standard file structure?

I have a lot of student's code to test, and their code is structured like this:

Project_Dir -> src -> edu -> collegeName-> courseName -> assignmentName -> (their classes here)

and for tests:

Project_Dir -> src -> edu -> collegeName-> courseName -> assignmentName -> tests -> (their tests here)

You'll notice that this does not follow the typical convention of:

${basedir}/src/main/java

and

${basedir}/src/test

When I try to test their code with maven test, it can't find any of their code (sourcecode or tests)

Is there some commandline argument I can use to tell maven to look in the correct place for their source code and tests? Or is there some way of dropping in a modified POM file to tell maven the same thing?

What if you want to choose a couple of test file to run from the command line. Try

mvn '-Dtest=yourpackage.*' test

And this question already have a answer here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM