fe9ff808368ea3d5cfc92eba5622a5200d3124b3
[policy/drools-applications.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * 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, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.controlloop.common.rules.test;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.fail;
25
26 import org.junit.AfterClass;
27 import org.junit.Ignore;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30
31
32 /**
33  * Tests NamedRunner. The tests don't do much, because all we really want to check is
34  * which tests are executed based on the {@link TestNames} annotation.
35  */
36 @RunWith(NamedRunner.class)
37 @TestNames(names = {"testAbc", "testDef", "testIgnore"}, prefixes = {"testGhi", "testJkl"})
38 public class NamedRunnerTest {
39
40     private static int testCount = 0;
41
42     @AfterClass
43     public static void tearDownAfterClass() {
44         assertEquals(5, testCount);
45     }
46
47     @Test
48     public void testAbc() {
49         checkTest();
50     }
51
52     @Test
53     public void testAbc2() {
54         fail("should not run");
55     }
56
57     @Test
58     public void testDef() {
59         checkTest();
60     }
61
62     @Test
63     @Ignore
64     public void testIgnore() {
65         fail("should not run");
66     }
67
68     @Test
69     public void testGhi1() {
70         checkTest();
71     }
72
73     @Test
74     public void testGhi2() {
75         checkTest();
76     }
77
78     @Test
79     public void testJkl() {
80         checkTest();
81     }
82
83
84     private static void checkTest() {
85         ++testCount;
86     }
87 }