1 package org.apache.maven.surefire.its;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.lang3.StringUtils;
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.SurefireLauncher;
26 import org.junit.Test;
27
28 import java.io.IOException;
29
30 import static org.junit.Assert.assertFalse;
31 import static org.junit.Assert.assertNotNull;
32
33 public class JUnit47RedirectOutputIT
34 extends SurefireJUnit4IntegrationTestCase
35 {
36 @Test
37 public void testPrintSummaryTrueWithRedirect()
38 throws Exception
39 {
40 final OutputValidator clean = unpack().redirectToFile( true ).addGoal( "clean" ).executeTest();
41 checkReports( clean );
42 }
43
44 @Test
45 public void testClassesParallel()
46 throws Exception
47 {
48 final OutputValidator clean =
49 unpack().redirectToFile( true ).parallelClasses().addGoal( "clean" ).executeTest();
50 checkReports( clean );
51 }
52
53 private void checkReports( OutputValidator validator )
54 throws IOException
55 {
56 String report = StringUtils.trimToNull(
57 validator.getSurefireReportsFile( "junit47ConsoleOutput.Test1-output.txt" ).readFileToString() );
58 assertNotNull( report );
59 String report2 = StringUtils.trimToNull(
60 validator.getSurefireReportsFile( "junit47ConsoleOutput.Test2-output.txt" ).readFileToString() );
61 assertNotNull( report2 );
62 assertFalse( validator.getSurefireReportsFile( "junit47ConsoleOutput.Test3-output.txt" ).exists() );
63 }
64
65
66 private SurefireLauncher unpack()
67 {
68 return unpack( "/junit47-redirect-output" );
69 }
70
71 }