File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\maven\MavenBuildSurefireFailedTest.java.html

1 package hudson.maven;
2
3 import hudson.model.Result;
4 import hudson.tasks.Shell;
5
6 import org.jvnet.hudson.test.Bug;
7 import org.jvnet.hudson.test.ExtractResourceSCM;
8 import org.jvnet.hudson.test.HudsonTestCase;
9
10 /**
11 * @author Olivier Lamy
12 */
13 public class MavenBuildSurefireFailedTest extends HudsonTestCase {
14
15 @Bug(8415)
16 public void testMaven2Unstable() throws Exception {
17 configureDefaultMaven();
18 MavenModuleSet m = createMavenProject();
19 m.setGoals( "test" );
20 m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip")));
21 assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get());
22 }
23
24 @Bug(8415)
25 public void testMaven2Failed() throws Exception {
26 configureDefaultMaven();
27 MavenModuleSet m = createMavenProject();
28 m.setGoals( "test -Dmaven.test.failure.ignore=false" );
29 m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip")));
30 assertBuildStatus(Result.FAILURE, m.scheduleBuild2(0).get());
31 }
32
33 @Bug(8415)
34 public void testMaven3Unstable() throws Exception {
35 MavenModuleSet m = createMavenProject();
36 m.setMaven( configureMaven3().getName() );
37 m.setGoals( "test" );
38 m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip")));
39 assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get());
40 }
41
42 @Bug(8415)
43 public void testMaven3Failed() throws Exception {
44 MavenModuleSet m = createMavenProject();
45 m.setMaven( configureMaven3().getName() );
46 m.setGoals( "test -Dmaven.test.failure.ignore=false" );
47 m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip")));
48 assertBuildStatus(Result.FAILURE, m.scheduleBuild2(0).get());
49 }
50
51 @Bug(14102)
52 public void testMaven3SkipPostBuilder() throws Exception {
53 MavenModuleSet m = createMavenProject();
54 m.setMaven( configureMaven3().getName() );
55 m.setGoals( "test" );
56 m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip")));
57 // run dummy command only if build state is SUCCESS
58 m.setRunPostStepsIfResult(Result.SUCCESS);
59 m.addPostBuilder(new Shell("no-valid-command"));
60 assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get());
61 }
62
63 @Bug(14102)
64 public void testMaven2SkipPostBuilder() throws Exception {
65 configureDefaultMaven();
66 MavenModuleSet m = createMavenProject();
67 m.setGoals( "test" );
68 m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip")));
69 // run dummy command only if build state is SUCCESS
70 m.setRunPostStepsIfResult(Result.SUCCESS);
71 m.addPostBuilder(new Shell("no-valid-command"));
72 assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get());
73 }
74 }
75