aboutsummaryrefslogtreecommitdiff
path: root/src/tester/Runner.hx
diff options
context:
space:
mode:
authorrc_05 <contact@rc-05.com>2024-05-14 01:07:07 +0200
committerrc_05 <contact@rc-05.com>2024-05-14 01:18:42 +0200
commit875e8b54c907c60682567a6f900cbf99bedf55c5 (patch)
tree44dc606fa92217781cb33393810b778ebd76cf36 /src/tester/Runner.hx
downloadhaxe-tester-875e8b54c907c60682567a6f900cbf99bedf55c5.tar.gz
First commit.
Diffstat (limited to 'src/tester/Runner.hx')
-rw-r--r--src/tester/Runner.hx47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/tester/Runner.hx b/src/tester/Runner.hx
new file mode 100644
index 0000000..77c273e
--- /dev/null
+++ b/src/tester/Runner.hx
@@ -0,0 +1,47 @@
+package tester;
+
+/**
+ Class for running the defined tests.
+**/
+class Runner {
+ var tests:Array<Test>;
+
+ 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');
+ }
+}