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.maven.surefire.its.fixture.OutputValidator;
23 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
24 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
25 import org.junit.Test;
26
27
28
29
30
31
32 public class JUnit4RunListenerIT
33 extends SurefireJUnit4IntegrationTestCase
34 {
35 private SurefireLauncher unpack()
36 {
37 return unpack( "/junit4-runlistener" );
38 }
39
40 @Test
41 public void testJUnit4RunListener()
42 throws Exception
43 {
44 final OutputValidator outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion(
45 "4.4" ).executeTest().verifyErrorFreeLog();
46 assertResults( outputValidator );
47 outputValidator.verifyTextInLog( "testRunStarted null" );
48 outputValidator.verifyTextInLog( "testFinished simpleTest" );
49 outputValidator.verifyTextInLog( "testRunFinished org.junit.runner.Result" );
50 }
51
52 @Test
53 public void testRunlistenerJunitCoreProvider()
54 throws Exception
55 {
56 final OutputValidator outputValidator =
57 unpack().addGoal( "-Dprovider=surefire-junit47" ).setJUnitVersion( "4.8.1" ).addGoal(
58 "-DjunitVersion=4.8.1" ).executeTest().verifyErrorFreeLog();
59 assertResults( outputValidator );
60 outputValidator.verifyTextInLog( "testRunStarted null" );
61 outputValidator.verifyTextInLog( "testFinished simpleTest" );
62 outputValidator.verifyTextInLog( "testRunFinished org.junit.runner.Result" );
63 }
64
65 private void assertResults( OutputValidator outputValidator )
66 {
67 outputValidator.assertTestSuiteResults( 1, 0, 0, 0 );
68 outputValidator.getTargetFile( "runlistener-output-1.txt" ).assertFileExists();
69 outputValidator.getTargetFile( "runlistener-output-2.txt" ).assertFileExists();
70 }
71
72
73 }