package tester; /** Class for running the defined tests. **/ class Runner { var tests:Array; public function new() { tests = new Array(); } /** Adds a new `test` to the test suite. **/ public function addTest(test:Test) { tests.push(test); } /** Runs the tests of the test suite, prints the outcome of each of them and the final results to standard output. **/ public function run() { var passedTests = 0; var failedTests = 0; for (index => test in tests) { Sys.println('--- TEST ${index+1}/${tests.length}: ${test.description} ---'); var outcome = test.run(); switch outcome { case Pass: passedTests++; Sys.println('PASSED ${test.description}'); case Fail(reason): failedTests++; Sys.println('FAILED ${test.description}: $reason'); } } Sys.println("--- RESULTS ---"); Sys.println('Total: ${tests.length}'); Sys.println('Passed: $passedTests'); Sys.println('Failed: $failedTests'); } }