Adding support for get test results in TestDriver.
authorlateralusX <lateralusx.github@gmail.com>
Fri, 25 Nov 2016 12:17:38 +0000 (13:17 +0100)
committerlateralusX <lateralusx.github@gmail.com>
Fri, 25 Nov 2016 12:17:38 +0000 (13:17 +0100)
Added support to pass in an instance of a TestDriverReporter class. If this
an instance of this class is passed in it will get the number of executed, skipped
and failed tests. This could be very useful for external runners that would like
to present the result of TestDriver executed tests.

mono/mini/TestDriver.cs

index fdd7a10466f2b5f4cbd410f1723cfe5fba5b0dc0..639c52539709b1d228f866f5d7b5caae0a24cc8b 100644 (file)
@@ -13,10 +13,22 @@ public class CategoryAttribute : Attribute
                get; set;
        }
 }
+public class TestDriverReporter
+{
+       public int FailedTests { get; private set; }
+       public int SkippedTests { get; private set; }
+       public int ExecutedTests { get; private set; }
+
+       public void ReportResults (int executed, int skipped, int failed) {
+               ExecutedTests = executed;
+               SkippedTests = skipped;
+               FailedTests = failed;
+       }
+};
 
 public class TestDriver {
 
-       static public int RunTests (Type type, string[] args) {
+       static public int RunTests(Type type, string[] args, TestDriverReporter reporter) {
                int failed = 0, ran = 0;
                int result, expected;
                int i, j, iterations;
@@ -135,11 +147,20 @@ public class TestDriver {
                        }
                }
 
+               if (reporter != null) {
+                       reporter.ReportResults (ran, nskipped, failed);
+               }
+
                //Console.WriteLine ("Regression tests: {0} ran, {1} failed in [{2}]{3}", ran, failed, type.Assembly.GetName().Name, type);
                return failed;
        }
+
+       static public int RunTests (Type type, string[] args) {
+               return RunTests (type, args, null);
+       }
+
        static public int RunTests (Type type) {
-               return RunTests (type, null);
+               return RunTests (type, null, null);
        }
 }