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

1 package hudson.maven.reporters;
2
3 import static hudson.maven.MojoInfoBuilder.mojoBuilder;
4 import static org.junit.Assert.assertFalse;
5 import static org.junit.Assert.assertTrue;
6 import hudson.maven.MojoInfo;
7 import hudson.maven.MojoInfoBuilder;
8
9 import org.junit.Before;
10 import org.junit.Test;
11
12 /**
13 * Regression test for the detection of test mojos in {@link SurefireArchiver}.
14 *
15 * @author kutzi
16 */
17 public class SurefireArchiverDetectTestMojosTest {
18
19 private SurefireArchiver surefireArchiver;
20
21 @Before
22 public void before() {
23 this.surefireArchiver = new SurefireArchiver();
24 }
25
26 @Test
27 public void shouldDetectMavenSurefire() {
28 MojoInfo mojo = mojoBuilder("org.apache.maven.plugins", "maven-surefire-plugin", "test").build();
29 assertTrue(this.surefireArchiver.isTestMojo(mojo));
30 }
31
32 @Test
33 public void shouldDetectMavenFailsafe() {
34 MojoInfo mojo = mojoBuilder("org.apache.maven.plugins", "maven-failsafe-plugin", "verify").build();
35 assertTrue(this.surefireArchiver.isTestMojo(mojo));
36 }
37
38 @Test
39 public void shouldDetectMavenFailsafe2() {
40 MojoInfo mojo = mojoBuilder("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test").build();
41 assertTrue(this.surefireArchiver.isTestMojo(mojo));
42 }
43
44 @Test
45 public void shouldDetectMavenSurefireSkip() {
46 MojoInfoBuilder builder = mojoBuilder("org.apache.maven.plugins", "maven-surefire-plugin", "test");
47 MojoInfo mojo = builder.copy()
48 .configValue("skip", "true").build();
49 assertFalse(this.surefireArchiver.isTestMojo(mojo));
50
51 mojo = builder.copy()
52 .version("2.4")
53 .configValue("skipTests", "true").build();
54 assertFalse(this.surefireArchiver.isTestMojo(mojo));
55
56 mojo = builder.copy()
57 .version("2.3")
58 .configValue("skipExec", "true").build();
59 assertFalse(this.surefireArchiver.isTestMojo(mojo));
60
61 // That's not a valid skip property:
62 mojo = builder.copy()
63 .configValue("skip--Exec", "true").build();
64 assertTrue(this.surefireArchiver.isTestMojo(mojo));
65 }
66
67 @Test
68 public void shouldDetectMavenJunitPlugin() {
69 MojoInfoBuilder builder = mojoBuilder("com.sun.maven", "maven-junit-plugin", "test");
70 MojoInfo mojo = builder.build();
71 assertTrue(this.surefireArchiver.isTestMojo(mojo));
72
73 mojo = builder.copy()
74 .configValue("skipTests", "true").build();
75 assertFalse(this.surefireArchiver.isTestMojo(mojo));
76 }
77
78 @Test
79 public void shouldDetectFlexMojoMavenPlugin() {
80 MojoInfoBuilder builder = mojoBuilder("org.sonatype.flexmojos", "flexmojos-maven-plugin", "test-run");
81 MojoInfo mojo = builder.build();
82 assertTrue(this.surefireArchiver.isTestMojo(mojo));
83
84 mojo = builder.copy()
85 .configValue("skipTest", "true").build();
86 assertFalse(this.surefireArchiver.isTestMojo(mojo));
87 }
88
89 @Test
90 public void shouldDetectOsgiTestPlugin() {
91 MojoInfoBuilder builder = mojoBuilder("org.sonatype.tycho", "maven-osgi-test-plugin", "test");
92
93 MojoInfo mojo = builder.build();
94 assertTrue(this.surefireArchiver.isTestMojo(mojo));
95
96 mojo = builder.copy().configValue("skipTest", "true").build();
97 assertFalse(this.surefireArchiver.isTestMojo(mojo));
98 }
99
100 @Test
101 public void shouldDetectTychoSurefirePlugin() {
102 MojoInfoBuilder builder = mojoBuilder("org.eclipse.tycho", "tycho-surefire-plugin", "test");
103
104 MojoInfo mojo = builder.build();
105 assertTrue(this.surefireArchiver.isTestMojo(mojo));
106
107 mojo = builder.copy().configValue("skipTest", "true").build();
108 assertFalse(this.surefireArchiver.isTestMojo(mojo));
109 }
110
111 @Test
112 public void shouldDetectMavenAndroidPlugin() {
113 MojoInfoBuilder builder = mojoBuilder("com.jayway.maven.plugins.android.generation2", "maven-android-plugin", "internal-integration-test")
114 .version("3.0.0-alpha-6");
115
116 MojoInfo mojo = builder.build();
117 assertTrue(this.surefireArchiver.isTestMojo(mojo));
118
119 mojo = builder.copy().configValue("skipTests", "true").build();
120 assertFalse(this.surefireArchiver.isTestMojo(mojo));
121 }
122
123 @Test
124 public void shouldDetectAndroidMavenPlugin() {
125 MojoInfoBuilder builder = mojoBuilder("com.jayway.maven.plugins.android.generation2", "android-maven-plugin", "internal-integration-test")
126 .version("3.0.0-alpha-6");
127
128 MojoInfo mojo = builder.build();
129 assertTrue(this.surefireArchiver.isTestMojo(mojo));
130
131 mojo = builder.copy().configValue("skipTests", "true").build();
132 assertFalse(this.surefireArchiver.isTestMojo(mojo));
133 }
134
135 @Test
136 public void shouldDetectGwtMavenPlugin() {
137 MojoInfoBuilder builder = mojoBuilder("org.codehaus.mojo", "gwt-maven-plugin", "test")
138 .version("1.2");
139
140 MojoInfo mojo = builder.build();
141 assertTrue(this.surefireArchiver.isTestMojo(mojo));
142
143 // that version of the plugin is too old
144 mojo = builder.copy().version("1.1").build();
145 assertFalse(this.surefireArchiver.isTestMojo(mojo));
146 }
147
148 @Test
149 public void shouldDetectSoapUiMavenPlugin() {
150 MojoInfoBuilder builder = mojoBuilder("eviware", "maven-soapui-plugin", "test");
151
152 MojoInfo mojo = builder.build();
153 assertTrue(this.surefireArchiver.isTestMojo(mojo));
154
155 mojo = builder.copy().configValue("skip", "true").build();
156 assertFalse(this.surefireArchiver.isTestMojo(mojo));
157 }
158
159 @Test
160 public void shouldDetectSoapUiProMavenPlugin() {
161 MojoInfoBuilder builder = mojoBuilder("eviware", "maven-soapui-pro-plugin", "test");
162
163 MojoInfo mojo = builder.build();
164 assertTrue(this.surefireArchiver.isTestMojo(mojo));
165
166 mojo = builder.copy().configValue("skip", "true").build();
167 assertFalse(this.surefireArchiver.isTestMojo(mojo));
168 }
169
170 @Test
171 public void shouldDetectToolkitResolverPlugin() {
172 MojoInfoBuilder builder = mojoBuilder("org.terracotta.maven.plugins", "toolkit-resolver-plugin", "toolkit-resolve-test");
173
174 MojoInfo mojo = builder.build();
175 assertTrue(this.surefireArchiver.isTestMojo(mojo));
176
177 mojo = builder.copy().configValue("skipTests", "true").build();
178 assertFalse(this.surefireArchiver.isTestMojo(mojo));
179 }
180
181 @Test
182 public void shouldDetectAnyMojoWithATestGoal() {
183 MojoInfoBuilder builder = mojoBuilder("some.weird.internal","test-mojo", "test");
184
185 MojoInfo mojo = builder.build();
186 assertTrue(this.surefireArchiver.isTestMojo(mojo));
187 }
188
189 @Test
190 public void shouldNotDetectNonTestGoal() {
191 MojoInfoBuilder builder = mojoBuilder("some.weird.internal","test-mojo", "verify");
192
193 MojoInfo mojo = builder.build();
194 assertFalse(this.surefireArchiver.isTestMojo(mojo));
195 }
196 }
197