View Javadoc
1   /*
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.common;
17  
18  import org.junit.runners.BlockJUnit4ClassRunner;
19  import org.junit.runners.model.FrameworkMethod;
20  import org.junit.runners.model.InitializationError;
21  import org.junit.runners.model.Statement;
22  
23  import java.lang.reflect.Method;
24  
25  /**
26   * JUnit Test Runner to run test SmokeTests.  Enables bookmark mode for test methods
27   * ending in Bookmark and navigation mode for test methods ending in Nav.
28   */
29  public class SmokeTestRunner extends BlockJUnit4ClassRunner {
30  
31      /**
32       * SmokeTestRunner constructor
33       * @param type
34       * @throws InitializationError
35       */
36      public SmokeTestRunner(Class<?> type) throws InitializationError {
37          super(type);
38      }
39  
40      @Override
41      protected Statement methodInvoker(FrameworkMethod method, Object test) {
42          Method testMethod = method.getMethod();
43          final String testClass = test.getClass().toString();
44          if (testMethod.getName().endsWith("Bookmark") ||
45             (testClass.endsWith("WDIT")) ||
46             (testClass.endsWith("BkMrkGen"))) {
47              ((SmokeTestBase) test).enableBookmarkMode();
48          } else if (testMethod.getName().endsWith("Nav") ||
49                    (testClass.endsWith("NavIT"))) {
50              ((SmokeTestBase) test).enableNavigationMode();
51          }
52          return super.methodInvoker(method, test);
53      }
54  }