views:

96

answers:

4

Actuality when i run tests they fails but i need to run them to get some .class files which are very important for my jar.

By default when test results fails , the jar is not build , could i add a setting in pom.xml which ignore that, so I can build the jar ignoring results from tests ?

I read something about "Maven Surefire Plugin" but I don't know how to use it...

+1  A: 
<properties>
<maven.test.skip>true</maven.test.skip>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>

http://jira.codehaus.org/browse/SUREFIRE-319

Or from command line

http://maven.apache.org/maven-1.x/plugins/test/properties.html

maven.test.error.ignore Yes Set this to true to ignore errors during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion maven.test.failure.ignore Yes Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion

I82Much
Thanks a lot for your post, i added that part and it worked , any way, my problem was not solved because , the .class files which result after running tests now are missing... and i need those... somehow... even if test results fails
sorry i was wrong, removing "<maven.test.skip>true</maven.test.skip>" part i get the right results
A: 

mvn -Dmaven.test.skip=true package skips the testing phase

to ignore test failures and keep maven from stopping you can add this to the section of the pom.xml:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <testFailureIgnore>true</testFailureIgnore>
    </configuration>
  </plugin>
smeg4brains
Thanks a lot for your post, i added that part and it worked , any way, my problem was not solved because , the .class files which result after running tests now are missing... and i need those... somehow... even if test results fails
i added a new part to the answer regarding surefire plugin config for ignoring test failures...hope that helps..
smeg4brains
`mvn -Dmaven.test.skip=true package skips the testing phase`. **No it doesn't!**. You can't skip a phase by using a system property. What it does is set a flag that skips execution of the surefire:test mojo and the compiler:test-compile mojo (possibly others) : http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#skip http://maven.apache.org/plugins/maven-compiler-plugin/testCompile-mojo.html#skip
seanizer
the nitpicking award goes to.........seanizer ;)
smeg4brains
That's not nitpicking, that's correctness. And all these answers suggesting to skip tests are incorrect anyway, they missed the point: the question is not about skipping tests, it's about ignoring tests failures.
Pascal Thivent
A: 

Use the maven option -Dmaven.test.skip=true

E.g. mvn package -Dmaven.test.skip=true

reverendgreen
Thanks a lot for your post, i added that part and it worked , any way, my problem was not solved because , the .class files which result after running tests now are missing... and i need those... somehow... even if test results fails
This will skip the tests, the question is more about ignoring failures.
Pascal Thivent
Thanks for helping !
+1  A: 

The solution is:

mvn -fn clean install

execute mvn --help for advanced options

Here's the excerpt for -fn

 -fn,--fail-never         NEVER fail the build, regardless
                          of project result
seanizer