fea4405410bc6314584ca4c2e3155499c098f151
[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     /*
63      * Note: this test is purposely marked with the "Ignore" annotation to verify that the
64      * NamedRunner skips over it, hence the sonar issue is being suppressed.
65      */
66     @Test
67     @Ignore
68     public void testIgnore() {      // NOSONAR
69         fail("should not run");
70     }
71
72     @Test
73     public void testGhi1() {
74         checkTest();
75     }
76
77     @Test
78     public void testGhi2() {
79         checkTest();
80     }
81
82     @Test
83     public void testJkl() {
84         checkTest();
85     }
86
87
88     private static void checkTest() {
89         ++testCount;
90     }
91 }