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.apache.maven.surefire.its.fixture.SurefireLauncher;
24  import org.junit.Test;
25  
26  /**
27   * Tests using the JUnit 47 provider to rerun failing tests with the cucumber runner. The main
28   * problem that the junit4 provider has with the cucumber runner is that the junit Description
29   * instance created by the runner has a null test class attribute. This requires that tests are
30   * rerun based on their description.
31   *
32   * @author mpkorstanje
33   */
34  public class JUnit47RerunFailingTestWithCucumberIT
35      extends SurefireJUnit4IntegrationTestCase {
36  
37      private SurefireLauncher unpack() {
38          return unpack("junit47-rerun-failing-tests-with-cucumber")
39              .setJUnitVersion("4.12");
40      }
41  
42      @Test
43      public void testRerunFailingErrorTestsFalse() {
44          unpack()
45              .maven()
46              .addGoal("-Dsurefire.rerunFailingTestsCount=" + 0)
47              .withFailure()
48              .executeTest()
49              .assertTestSuiteResults(1, 0, 1, 0, 0);
50      }
51  
52      @Test
53      public void testRerunFailingErrorTestsWithOneRetry() {
54          unpack()
55              .maven()
56              .addGoal("-Dsurefire.rerunFailingTestsCount=" + 1)
57              .withFailure()
58              .executeTest()
59              .assertTestSuiteResults(1, 0, 1, 0, 0);
60      }
61  
62      @Test
63      public void testRerunFailingErrorTestsTwoRetry() {
64          unpack()
65              .maven()
66              .addGoal("-Dsurefire.rerunFailingTestsCount=" + 2)
67              .executeTest()
68              .assertTestSuiteResults(1, 0, 0, 0, 2);
69      }
70  
71  }