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