Vinnie
Vinnie

Reputation: 12720

Conditionally run JUnit tests from Maven

In Maven, is there some way to specify that JUnit tests only run when there are some source code changes?

For instance, I see this message

[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ my_project ---
[INFO] Nothing to compile - all classes are up to date

Now -since no code was compiled (since there were no changes from the last compile), I'd prefer that no tests run. Is this possible?

Upvotes: 4

Views: 608

Answers (1)

Manfred Moser
Manfred Moser

Reputation: 29912

Your project setup should be broken up into separate modules. However if you can not do that you could set the maven.test.skip property in your profiles in which you want no tests to be run. See more about skipping tests on the site.

You are talking about a war project. Typically a war project should NOT have any code in it, but rather just some configuration and stuff like html, jsp, css and java script and bundle jar projects, that contain java code. The jar projects will have the code. And if you do integration tests a good practice is to have them in separate modules.

Different war configs can be in profiles or potentially also in separate modules using the war overlay feature of the maven war plugin.

Upvotes: 1

Related Questions