'Is it at all possible to execute 'mvn test' when tests are in src/main/java and not in src/test/java [duplicate]
I have inherited a project which has over 100 Junit test classes. The problem is the unit test sources and main source files are in the same folder.There is no src/test/java folder.This can be built with ant, but with maven I am not able to get maven run the tests unless I refactor every test in to src/test folder. Is there a way to specify the a directory other than src/test/java from where mvn can run the tests?
Solution 1:[1]
Move the tests into src/test
. If you've inherited the project then it's time to fix mistakes.
From src/test
, generate a list of test classes. If there's a naming convention:
find . -name 'Test*.java' -or -name '*Test.java' >../test-classes
If they're all using JUnit:
fgrep -lR 'junit.' >../test-classes
Then move those files into src/test
by scripting your scm.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |