View Javadoc
1   package org.apache.maven.surefire.its.jiras;
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.junit.Test;
25  
26  /**
27   * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1146">SUREFIRE-1146</a>
28   */
29  public class Surefire1146RerunFailedAndParameterized
30      extends SurefireJUnit4IntegrationTestCase
31  {
32      
33      @Test
34      public void testsAreRerun()
35      {
36          OutputValidator outputValidator = unpack( "surefire-1146-rerunFailingTests-with-Parameterized" ).executeTest();
37          verify(outputValidator, 8, 0, 0, 0, 5);
38      }
39  
40      private void verify( OutputValidator outputValidator, int run, int failures, int errors, int skipped, int flakes )
41      {
42          outputValidator.verifyTextInLog( "Flakes:" );
43          outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionParameterizedTest.flakyTest[0: (Test11); Test12; Test13;](jiras.surefire1146.CustomDescriptionParameterizedTest)" );
44          outputValidator.verifyTextInLog( "Run 1: CustomDescriptionParameterizedTest.flakyTest:" );
45          outputValidator.verifyTextInLog( "Run 2: CustomDescriptionParameterizedTest.flakyTest:" );
46          outputValidator.verifyTextInLog( "Run 3: PASS" );
47  
48          outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest.flakyTest[0: (Test11), Test12, Test13;](jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest)" );
49          outputValidator.verifyTextInLog( "Run 1: CustomDescriptionWithCommaParameterizedTest.flakyTest:" );
50          outputValidator.verifyTextInLog( "Run 2: CustomDescriptionWithCommaParameterizedTest.flakyTest:" );
51          outputValidator.verifyTextInLog( "Run 3: PASS" );
52          
53          outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest.flakyTest[2: (Test31), Test32, Test33;](jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest)" );
54          outputValidator.verifyTextInLog( "Run 1: CustomDescriptionWithCommaParameterizedTest.flakyTest:" );
55          outputValidator.verifyTextInLog( "Run 2: PASS" );
56          
57          outputValidator.verifyTextInLog( "jiras.surefire1146.SimpleParameterizedTest.flakyTest[0](jiras.surefire1146.SimpleParameterizedTest)" );
58          outputValidator.verifyTextInLog( "Run 1: SimpleParameterizedTest.flakyTest:" );
59          outputValidator.verifyTextInLog( "Run 2: SimpleParameterizedTest.flakyTest:" );
60          outputValidator.verifyTextInLog( "Run 3: PASS" );
61          
62          outputValidator.verifyTextInLog( "jiras.surefire1146.StandardTest.flakyTest(jiras.surefire1146.StandardTest)" );
63          outputValidator.verifyTextInLog( "Run 1: StandardTest.flakyTest:" );
64          outputValidator.verifyTextInLog( "Run 2: PASS" );
65  
66          verifyStatistics( outputValidator, run, failures, errors, skipped, flakes );
67      }
68      
69      private void verifyStatistics( OutputValidator outputValidator, int run, int failures, int errors, int skipped,
70                                     int flakes )
71      {
72          outputValidator.verifyTextInLog( "Tests run: " + run + ", Failures: " + failures + ", Errors: " + errors
73                                               + ", Skipped: " + skipped + ", Flakes: " + flakes );
74      }
75  }