1 /** 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (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.mozilla.org/MPL/MPL-1.1.html 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 import org.as2lib.app.exec.Process; 18 import org.as2lib.test.unit.TestResult; 19 import org.as2lib.test.unit.TestCaseResult; 20 import org.as2lib.test.unit.TestCaseMethodInfo; 21 22 /** 23 * {@code TestRunner} is the definition for a process that executes a {@code Test}. 24 * 25 * <p>It is the internal mechianism for the execution of a {@code Test}. Any 26 * {@code Test} has to refer to its {@code TestRunner}. 27 * 28 * <p>Since {@code TestRunner} extends {@link Process} it is possible to add 29 * all listeners for {@code Process} to a {@code TestRunner}. 30 * 31 * <p>Example for adding a Listener to the execution of a {@link TestCase}: 32 * <code> 33 * var testCase:TestCase = new MyTestCase(); 34 * var testRunner:TestRunner = testCase.getTestRunner(); 35 * 36 * // add a listener to log the events of the test 37 * testRunner.addListener(new LoggerTestListener()); 38 * 39 * // start the execution of the testcase 40 * testCase.run(); 41 * </code> 42 * 43 * <p>{@code TestRunner} is part of the unit testing MVC construct. {@code TestRunner} 44 * acts as controller, {@link TestResult} acts as model and all listeners act 45 * as view. {@code TestResult} can be accessed by {@code #getTestResult}. 46 * 47 * <p>The seperation of {@code Test} & {@code TestRunner} is to save the developer 48 * of a {@code TestCase} that contains all its execution details (can lead to 49 * many reserved fields that might be used by the unit-test developer. In this way 50 * only two fields ((@link Test#getTestRunner} & {@link Test#run}) are reserved. 51 * 52 * @author Martin Heidegger 53 * @version 2.0 54 */ 55 interface org.as2lib.test.unit.TestRunner extends Process { 56 57 /** 58 * Returns the {@code TestResult} to the {@code Test} executed by the {@code TestRunner}. 59 * 60 * <p>The returned {@code TestResult} may not be complete. This is the case 61 * if the test has not been executed or has not finished yet. 62 * 63 * @return {@link TestResult} for the {@code Test} that contains all informations 64 */ 65 public function getTestResult(Void):TestResult; 66 67 /** 68 * Returns the current executing {@code TestCaseResult}. 69 * 70 * <p>It is necessary to get the {@code TestCaseResult} for the {@code TestCase} 71 * that just gets executed because there can be more than one {@code TestCase} 72 * available within a {@code TestResult}. 73 * 74 * @return {@code TestResult} to the current executing {@code TestCase} 75 */ 76 public function getCurrentTestCase(Void):TestCaseResult; 77 78 /** 79 * Returns the current executing {@code TestCaseMethodInfo}. 80 * 81 * <p>It is necessary to get the {@code TestCaseMethodInfo} for the method 82 * that just gets executed because there can be more than one methods available 83 * within a {@code TestCaseResult}. 84 * 85 * @return informations about the current executing method 86 * @see #getCurrentTestCase 87 */ 88 public function getCurrentTestCaseMethodInfo(Void):TestCaseMethodInfo; 89 }