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  /**
29   * Test project using -Dtest=mtClass#myMethod+myMethod2,secondClass#testMethod
30   *
31   * @author <a href="mailto:ytsolar@gmail.com">rainLee</a>
32   */
33  public class TestMultipleMethodsIT
34      extends SurefireJUnit4IntegrationTestCase
35  {
36  
37      private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0";
38  
39      public OutputValidator multipleMethod( String projectName, String... goals )
40          throws Exception
41      {
42          SurefireLauncher launcher = unpack( projectName );
43          for ( String goal : goals )
44          {
45              launcher.addGoal( goal );
46          }
47          return launcher.showErrorStackTraces().debugLogging()
48              .executeTest()
49              .verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
50      }
51  
52      @Test
53      public void testJunit44()
54          throws Exception
55      {
56          multipleMethod( "junit44-multiple-methods" );
57      }
58  
59      @Test
60      public void testJunit48Provider4()
61          throws Exception
62      {
63          multipleMethod( "junit48-multiple-methods", "-P surefire-junit4" );
64      }
65  
66      @Test
67      public void testJunit48Provider47()
68          throws Exception
69      {
70          multipleMethod( "junit48-multiple-methods", "-P surefire-junit47" )
71              .verifyTextInLog( RUNNING_WITH_PROVIDER47 );
72      }
73  
74  }