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.surefire.its.fixture.OutputValidator;
22  import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
23  import org.apache.maven.surefire.its.fixture.SurefireLauncher;
24  import org.junit.Test;
25  
26  /**
27   *
28   */
29  public class Surefire828EmptyGroupExprIT extends SurefireJUnit4IntegrationTestCase {
30      // !CategoryC
31      @Test
32      public void testJUnitRunEmptyGroups() {
33          OutputValidator validator =
34                  unpackJUnit().sysProp("profile", "emptyGroups").executeTest();
35          validator.verifyErrorFreeLog();
36          validator.assertTestSuiteResults(5, 0, 0, 0);
37          validator.verifyTextInLog("catA: 2");
38          validator.verifyTextInLog("catB: 2");
39          validator.verifyTextInLog("catC: 0");
40          validator.verifyTextInLog("catNone: 1");
41          validator.verifyTextInLog("NoCategoryTest.CatNone: 1");
42      }
43  
44      // CategoryA && CategoryB
45      @Test
46      public void testJUnitRunEmptyExcludeGroups() {
47          OutputValidator validator =
48                  unpackJUnit().sysProp("profile", "emptyExcludedGroups").executeTest();
49          validator.verifyErrorFreeLog();
50          validator.assertTestSuiteResults(2, 0, 0, 0);
51          validator.verifyTextInLog("catA: 1");
52          validator.verifyTextInLog("catB: 1");
53          validator.verifyTextInLog("catC: 0");
54          validator.verifyTextInLog("catNone: 0");
55          validator.verifyTextInLog("mA: 1");
56          validator.verifyTextInLog("mB: 1");
57          validator.verifyTextInLog("mC: 0");
58      }
59  
60      // CategoryA && CategoryB
61      @Test
62      public void testTestNGRunEmptyExcludeGroups() {
63          OutputValidator validator =
64                  unpackTestNG().sysProp("profile", "emptyExcludedGroups").executeTest();
65          validator.verifyErrorFreeLog();
66          validator.assertTestSuiteResults(2, 0, 0, 0);
67          validator.verifyTextInLog("BasicTest.testInCategoriesAB()");
68          validator.verifyTextInLog("CategoryCTest.testInCategoriesAB()");
69      }
70  
71      // !CategoryC
72      @Test
73      public void testTestNGRunEmptyGroups() {
74          OutputValidator validator =
75                  unpackTestNG().sysProp("profile", "emptyGroups").executeTest();
76          validator.verifyErrorFreeLog();
77          validator.assertTestSuiteResults(8, 0, 0, 0);
78          validator.verifyTextInLog("catA: 2");
79          validator.verifyTextInLog("catB: 2");
80          validator.verifyTextInLog("catC: 0");
81          validator.verifyTextInLog("catNone: 1");
82          validator.verifyTextInLog("mA: 2");
83          validator.verifyTextInLog("mB: 2");
84          validator.verifyTextInLog("mC: 0");
85          validator.verifyTextInLog("NoCategoryTest.CatNone: 1");
86      }
87  
88      private SurefireLauncher unpackJUnit() {
89          return unpack("surefire-828-emptyGroupExpr-junit48");
90      }
91  
92      private SurefireLauncher unpackTestNG() {
93          return unpack("surefire-828-emptyGroupExpr-testng");
94      }
95  }