1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 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 17 package vogar.target.junit.junit3; 18 19 import java.lang.annotation.Annotation; 20 import java.util.List; 21 import junit.framework.Test; 22 import junit.framework.TestCase; 23 24 /** 25 * A factory for creating components of a {@link TestCase} derived test suite. 26 * 27 * @param <S> the type of the 'suite' component 28 * @param <T> the type of the 'test' component 29 */ 30 public interface TestCaseFactory<S,T> { 31 32 /** 33 * Determine whether class validation is done eagerly up front and so will result in one class 34 * level error or not. 35 * 36 * <p>If this returns true then it takes responsibility for validating the test class, using 37 * {@link TestCaseTransformer#validateTestClass(Class)}. 38 * 39 * @return true if the class validation should be eagerly, false otherwise. 40 */ eagerClassValidation()41 boolean eagerClassValidation(); 42 43 /** 44 * Create the 'test' for the method. 45 */ createTest(Class<? extends TestCase> testClass, String methodName, Annotation[] annotations)46 T createTest(Class<? extends TestCase> testClass, String methodName, Annotation[] annotations); 47 48 /** 49 * Create a 'test' that when run will throw the supplied throwable. 50 */ createFailingTest(Class<? extends Test> testClass, String name, Throwable throwable)51 T createFailingTest(Class<? extends Test> testClass, String name, Throwable throwable); 52 53 /** 54 * Constructs a test suite from the given class and list of tests. 55 */ createSuite(Class<? extends TestCase> testClass, List<T> tests)56 S createSuite(Class<? extends TestCase> testClass, List<T> tests); 57 } 58