1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.surefire.its.jiras;
20
21 import java.util.ArrayList;
22
23 import org.apache.maven.surefire.its.fixture.OutputValidator;
24 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
25 import org.apache.maven.surefire.its.fixture.SurefireVerifierException;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.Parameterized;
29
30 import static org.junit.Assert.fail;
31 import static org.junit.runners.Parameterized.Parameter;
32 import static org.junit.runners.Parameterized.Parameters;
33
34
35
36
37
38
39 @RunWith(Parameterized.class)
40 public class Surefire1158RemoveInfoLinesIT extends SurefireJUnit4IntegrationTestCase {
41
42 @Parameters(name = "{0}")
43 public static Iterable<Object[]> data() {
44 ArrayList<Object[]> args = new ArrayList<>();
45 args.add(new Object[] {"junit-option-ff", "JUnitTest", "-ff", "surefire-junit47", false, true});
46 args.add(new Object[] {"testng-option-ff", "TestNGSuiteTest", "-ff", "surefire-testng", false, false});
47 args.add(new Object[] {"junit-option-X", "JUnitTest", "-X", "surefire-junit47", true, true});
48 args.add(new Object[] {"testng-option-X", "TestNGSuiteTest", "-X", "surefire-testng", true, false});
49 args.add(new Object[] {"junit-option-e", "JUnitTest", "-e", "surefire-junit47", true, true});
50 args.add(new Object[] {"testng-option-e", "TestNGSuiteTest", "-e", "surefire-testng", true, false});
51 return args;
52 }
53
54 @Parameter(0)
55 @SuppressWarnings("checkstyle:visibilitymodifier")
56 public String description;
57
58 @Parameter(1)
59 @SuppressWarnings("checkstyle:visibilitymodifier")
60 public String testToRun;
61
62 @Parameter(2)
63 @SuppressWarnings("checkstyle:visibilitymodifier")
64 public String cliOption;
65
66 @Parameter(3)
67 @SuppressWarnings("checkstyle:visibilitymodifier")
68 public String provider;
69
70 @Parameter(4)
71 @SuppressWarnings("checkstyle:visibilitymodifier")
72 public boolean printsInfoLines;
73
74 @Parameter(5)
75 @SuppressWarnings("checkstyle:visibilitymodifier")
76 public boolean isJUnit;
77
78 @Test
79 public void shouldRunWithCliOption() {
80 OutputValidator validator = assertTest();
81 if (isJUnit) {
82 assertJUnitTestLogs(validator);
83 } else {
84 assertTestNGTestLogs(validator);
85 }
86 }
87
88 private OutputValidator assertTest() {
89 final String[] cli = {"--batch-mode"};
90 return unpack("/surefire-1158-remove-info-lines", "_" + description, cli)
91 .sysProp("provider", provider)
92 .addGoal(cliOption)
93 .setTestToRun(testToRun)
94 .executeTest()
95 .verifyErrorFreeLog()
96 .assertTestSuiteResults(1, 0, 0, 0);
97 }
98
99 private void assertJUnitTestLogs(OutputValidator validator) {
100 try {
101 validator.verifyTextInLog("Surefire report directory:");
102 validator.verifyTextInLog(
103 "Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider");
104 validator.verifyTextInLog("parallel='none', perCoreThreadCount=true, threadCount=0, "
105 + "useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, "
106 + "threadCountMethods=0, parallelOptimized=true");
107 if (!printsInfoLines) {
108 fail();
109 }
110 } catch (SurefireVerifierException e) {
111 if (printsInfoLines) {
112 fail();
113 }
114 }
115 }
116
117 private void assertTestNGTestLogs(OutputValidator validator) {
118 try {
119 validator.verifyTextInLog("Surefire report directory:");
120 validator.verifyTextInLog("Using configured provider org.apache.maven.surefire.testng.TestNGProvider");
121 validator.verifyTextInLog("Configuring TestNG with: TestNGMapConfigurator");
122 if (!printsInfoLines) {
123 fail();
124 }
125 } catch (SurefireVerifierException e) {
126 if (printsInfoLines) {
127 fail();
128 }
129 }
130 }
131 }