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 java.io.IOException;
23  import org.apache.maven.it.VerificationException;
24  import org.apache.maven.surefire.its.fixture.*;
25  import org.junit.Test;
26  
27  import static org.junit.Assert.assertFalse;
28  import static org.junit.Assert.assertTrue;
29  
30  /**
31   * Test Surefire-740 Truncated comma with non us locale
32   *
33   * @author Kristian Rosenvold
34   */
35  public class Surefire772NoFailsafeReportsIT
36      extends SurefireJUnit4IntegrationTestCase
37  {
38  
39      @Test
40      public void testReportGeneration()
41          throws Exception
42      {
43          final OutputValidator site =
44              unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();
45  
46          assertSurefireReportPresent( site );
47          assertNoFailsefeReport( site );
48      }
49  
50      @Test
51      public void testSkippedFailsafeReportGeneration()
52          throws Exception
53      {
54          final OutputValidator validator = unpack().activateProfile(
55              "skipFailsafe" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();
56          assertSurefireReportPresent( validator );
57          assertNoFailsefeReport( validator );
58  
59      }
60  
61      @Test
62      public void testForcedFailsafeReportGeneration()
63          throws Exception
64      {
65          final OutputValidator validator = unpack().activateProfile(
66              "forceFailsafe" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();
67          assertSurefireReportPresent( validator );
68          assertFailsafeReport( validator );
69      }
70  
71      @Test
72      public void testSkipForcedFailsafeReportGeneration()
73          throws Exception
74      {
75          final OutputValidator validator = unpack().activateProfile( "forceFailsafe" ).activateProfile(
76              "skipFailsafe" ).addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();
77  
78          assertSurefireReportPresent( validator );
79          assertNoFailsefeReport( validator );
80      }
81  
82      private void assertNoFailsefeReport( OutputValidator site )
83      {
84          TestFile siteFile = site.getSiteFile( "failsafe-report.html" );
85          assertFalse( "Expecting no failsafe report file", siteFile.isFile() );
86      }
87  
88      private void assertFailsafeReport( OutputValidator site )
89      {
90          TestFile siteFile = site.getSiteFile( "failsafe-report.html" );
91          assertTrue( "Expecting no failsafe report file", siteFile.isFile() );
92      }
93  
94      private void assertSurefireReportPresent( OutputValidator site )
95      {
96          TestFile siteFile = site.getSiteFile( "surefire-report.html" );
97          assertTrue( "Expecting surefire report file", siteFile.isFile() );
98      }
99  
100     private SurefireLauncher unpack()
101         throws VerificationException, IOException
102     {
103         final SurefireLauncher unpack = unpack( "surefire-772-no-failsafe-reports" );
104         unpack.maven().deleteSiteDir().skipClean().failNever().assertNotPresent( "site" );
105         return unpack;
106     }
107 
108 }