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.Test;
24  
25  import static org.hamcrest.Matchers.containsString;
26  import static org.hamcrest.Matchers.is;
27  
28  /**
29   * Test surefire-report on TestNG test
30   *
31   * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
32   */
33  public class CheckTestNgReportTestIT
34      extends SurefireJUnit4IntegrationTestCase
35  {
36      @Test
37      public void testNgReport()
38          throws Exception
39      {
40          unpack( "/testng-simple" )
41                  .sysProp( "testNgVersion", "5.7" )
42                  .sysProp( "testNgClassifier", "jdk15" )
43                  .addSurefireReportGoal()
44                  .executeCurrentGoals()
45                  .verifyErrorFree( 3 )
46                  .getSiteFile( "surefire-report.html" )
47                  .assertFileExists();
48      }
49  
50      @Test
51      public void shouldNotBeVerbose()
52          throws Exception
53      {
54          unpack( "/testng-simple" )
55              .sysProp( "testNgVersion", "5.10" )
56              .sysProp( "testNgClassifier", "jdk15" )
57              .executeTest()
58              .verifyErrorFreeLog()
59              .assertThatLogLine( containsString( "[Parser] Running:" ), is( 0 ) );
60      }
61  
62      @Test
63      public void shouldBeVerbose()
64          throws Exception
65      {
66          unpack( "/testng-simple" )
67              .sysProp( "testNgVersion", "5.10" )
68              .sysProp( "testNgClassifier", "jdk15" )
69              .sysProp( "surefire.testng.verbose", "10" )
70              .executeTest()
71              .verifyErrorFreeLog()
72              .assertThatLogLine( containsString( "[Parser] Running:" ), is( 1 ) );
73      }
74  }