Merge pull request #4023 from lateralusX/jlorenss/test-driver-reporter
authorJohan Lorensson <lateralusx.github@gmail.com>
Tue, 29 Nov 2016 07:47:12 +0000 (08:47 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Nov 2016 07:47:12 +0000 (08:47 +0100)
Adding support to get test results back from TestDriver.

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);
        }
 }