View Javadoc

1   package org.apache.maven.surefire.its;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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   * JUnit4 RunListener Integration Test.
29   *
30   * @author <a href="mailto:matthew.gilliard@gmail.com">Matthew Gilliard</a>
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();   // Todo: Fix junitVesion
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  }