View Javadoc

1   package org.apache.maven.surefire.its;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  
22  import org.apache.maven.it.Verifier;
23  import org.apache.maven.it.util.ResourceExtractor;
24  import org.apache.maven.surefire.its.misc.HelperAssertions;
25  
26  import java.io.File;
27  import java.util.Arrays;
28  import java.util.List;
29  
30  /**
31   * Test simple TestNG suite XML file
32   *
33   * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
34   */
35  public class CheckTestNgSuiteXmlIT
36      extends AbstractSurefireIntegrationTestClass
37  {
38      public void testTestNgSuiteXml()
39          throws Exception
40      {
41          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/testng-suite-xml" );
42  
43          Verifier verifier = new Verifier( testDir.getAbsolutePath() );
44          List<String> goals = getInitialGoals();
45          goals.add( "test" );
46          executeGoals( verifier, goals );
47          verifier.verifyErrorFreeLog();
48          verifier.resetStreams();
49  
50          HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, testDir );
51      }
52  
53      public void testTestNgSuiteXmlForkModeAlways()
54          throws Exception
55      {
56          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/testng-suite-xml" );
57  
58          Verifier verifier = new Verifier( testDir.getAbsolutePath() );
59          List<String> goals = getInitialGoals();
60          goals.addAll( Arrays.asList( new String[]{ "test", "-DforkMode=always" } ) );
61          executeGoals( verifier, goals );
62          verifier.verifyErrorFreeLog();
63          verifier.resetStreams();
64  
65          HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, testDir );
66      }
67  }