View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.surefire.its.jiras;
20  
21  import org.apache.maven.it.VerificationException;
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.apache.maven.surefire.its.fixture.TestFile;
26  import org.junit.Test;
27  
28  import static org.junit.Assert.assertFalse;
29  import static org.junit.Assert.assertTrue;
30  
31  /**
32   * Test Surefire-740 Truncated comma with non us locale
33   *
34   * @author Kristian Rosenvold
35   */
36  public class Surefire772NoFailsafeReportsIT extends SurefireJUnit4IntegrationTestCase {
37  
38      @Test
39      public void testReportGeneration() throws Exception {
40          final OutputValidator site =
41                  unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();
42  
43          assertSurefireReportPresent(site);
44          assertNoFailsefeReport(site);
45      }
46  
47      @Test
48      public void testSkippedFailsafeReportGeneration() throws Exception {
49          final OutputValidator validator = unpack().activateProfile("skipFailsafe")
50                  .addFailsafeReportOnlyGoal()
51                  .addSurefireReportOnlyGoal()
52                  .executeCurrentGoals();
53          assertSurefireReportPresent(validator);
54          assertNoFailsefeReport(validator);
55      }
56  
57      @Test
58      public void testForcedFailsafeReportGeneration() throws Exception {
59          final OutputValidator validator = unpack().activateProfile("forceFailsafe")
60                  .addFailsafeReportOnlyGoal()
61                  .addSurefireReportOnlyGoal()
62                  .executeCurrentGoals();
63          assertSurefireReportPresent(validator);
64          assertFailsafeReport(validator);
65      }
66  
67      @Test
68      public void testSkipForcedFailsafeReportGeneration() throws Exception {
69          final OutputValidator validator = unpack().activateProfile("forceFailsafe")
70                  .activateProfile("skipFailsafe")
71                  .addFailsafeReportOnlyGoal()
72                  .addSurefireReportOnlyGoal()
73                  .executeCurrentGoals();
74  
75          assertSurefireReportPresent(validator);
76          assertNoFailsefeReport(validator);
77      }
78  
79      private void assertNoFailsefeReport(OutputValidator site) {
80          TestFile siteFile = site.getSiteFile("failsafe-report.html");
81          assertFalse("Expecting no failsafe report file", siteFile.isFile());
82      }
83  
84      private void assertFailsafeReport(OutputValidator site) {
85          TestFile siteFile = site.getSiteFile("failsafe-report.html");
86          assertTrue("Expecting no failsafe report file", siteFile.isFile());
87      }
88  
89      private void assertSurefireReportPresent(OutputValidator site) {
90          TestFile siteFile = site.getSiteFile("surefire-report.html");
91          assertTrue("Expecting surefire report file", siteFile.isFile());
92      }
93  
94      private SurefireLauncher unpack() throws VerificationException {
95          final SurefireLauncher unpack = unpack("surefire-772-no-failsafe-reports");
96          unpack.maven().deleteSiteDir().skipClean().failNever().verifyFileNotPresent("site");
97          return unpack;
98      }
99  }