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.app.exec.AbstractProcess;
    19  import org.as2lib.test.unit.LoggerTestListener;
    20  import org.as2lib.test.unit.TestSuiteFactory;
    21  import org.as2lib.test.unit.TestSuite;
    22  
    23  /**
    24   * Prepared configuration to execute Testcases.
    25   * <p>Use this class to simplify your configuration for the execution of Testcases.
    26   * <p>As common for as2lib configuration you can use this configuration within your application
    27   * execution to start and configure a TestSystem.
    28   * 
    29   * Example:
    30   * <code>
    31   *   import org.as2lib.app.conf.AbstractConfiguration;
    32   *   import com.domain.test.*
    33   *   
    34   *   class main.Configuration extends AbstractConfiguration {
    35   *     public static function init(Void):Void {
    36   *       init(UnitTestExecution);
    37   *     }
    38   *     
    39   *     public function setReferences(Void):Void {
    40   *       use(MyTestCase);
    41   *       use(MyTestCase2);
    42   *       use(MyTestCase3);
    43   *     }
    44   *   }
    45   * </code>
    46   *
    47   * @author Martin Heidegger
    48   * @version 1.0
    49   */
    50  class org.as2lib.app.conf.UnitTestExecution extends AbstractProcess implements Process {
    51  	
    52  	/**
    53  	 * Runs all available Testcases.
    54  	 */
    55  	public function run(Void):Void {
    56  		
    57  		// Execute all Testcases that are available at runtime
    58  		var factory:TestSuiteFactory = new TestSuiteFactory();
    59  		
    60  		var testSuite:TestSuite = factory.collectAllTestCases();
    61  		testSuite.addListener(LoggerTestListener.getInstance());
    62  		
    63  		// Starts the Runner as a subprocess.
    64  		startSubProcess(testSuite);
    65  	}
    66  }