i have 2 different tests
public class testcase1 {
@Test
public void testcase1() {
System.out.println("test1 ");
}
@Test
public void testcase2() {
System.out.println("test 2 ");
}
@Test
public void testcase3() {
Assert.assertTrue(false);
}
}
when i use mvn clean test
in terminal its execute all testcases and i git the report but its mark as build fail
here is the log
[ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 7.588 s <<< FAILURE! - in TestSuite
[ERROR] fail1.testcase2.testcase2 Time elapsed: 0.012 s <<< FAILURE!
java.lang.AssertionError: did not expect to find [true] but found [false]
at fail1.testcase2.testcase2(testcase2.java:10)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] testcase2.testcase2:10 did not expect to find [true] but found [false]
[INFO]
[ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 59.248 s
[INFO] Finished at: 2019-12-02T07:30:00+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test) on project neeewdev1: There are test failures.
[ERROR]
[ERROR] Please refer to /home/neeewdev1/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
please some can you explain why when testng result fail build also fail? and how can i solve this problem?
You are trying to test the app not build it. Anyway, if you really want to build it and skip test, you should run
mvn clean install -DskipTest
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application
either you can skip the test or if you still want to build the project even if there are test failures then you can use **<testFailureIgnore>true</testFailureIgnore>**
in pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
Use this option -Dmaven.test.failure.ignore
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.