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.SurefireJUnit4IntegrationTestCase;
23  import org.junit.Assume;
24  import org.junit.Before;
25  import org.junit.Test;
26  
27  /**
28   * Tests the JUnit 47 provider with the cucumber runner. At the moment, they don't play along that perfectly (minor
29   * glitches in the reports with parallel=classes), but at least all tests are executed, the execution times are counted
30   * correctly and failing tests are reported. The main problem that the junit47 provider has with the cucumber runner is
31   * that the junit Description instance created by the runner has a null test class attribute.
32   * 
33   * @author agudian
34   */
35  public class Junit47WithCucumberIT
36      extends SurefireJUnit4IntegrationTestCase
37  {
38  
39      @Before
40      public void assumeJdk16()
41      {
42          Assume.assumeTrue( System.getProperty( "java.version" ).compareTo( "1.6" ) > 0 );
43      }
44  
45      @Test
46      public void testWithoutParallel()
47      {
48          // 8 tests in total is what's probably correct
49          doTest( "none", 8 );
50      }
51  
52      @Test
53      public void testWithParallelClasses()
54      {
55          // with parallel=classes, we get 9 tests in total,
56          // as the dummy "scenario" test entry is reported twice: once as success, and once with the failure from the
57          // failing test step
58          doTest( "classes", 9 );
59      }
60  
61      private void doTest( String parallel, int total )
62      {
63          unpack( "junit47-cucumber" )
64                  .sysProp( "parallel", parallel )
65                  .sysProp( "threadCount", "2" )
66                  .executeTest()
67                  .assertTestSuiteResults( total, 0, 2, 0 );
68      }
69  }