public ITest LoadTests(IEnumerable<string> assemblies) { var testRunner = new SimpleTestRunner(); var enumerable = assemblies as IList<string> ?? assemblies.ToList(); _log.Debug("Creating NUnit package for files " + string.Join(", ", enumerable)); var package = new TestPackage("", enumerable.ToList()); package.Settings["RuntimeFramework"] = new RuntimeFramework(RuntimeType.Net, Environment.Version); package.Settings["UseThreadedRunner"] = false; // lock (this) // { _log.Debug("Loading NUnit package: " + package); bool load = testRunner.Load(package); if (!load) { throw new Exception("Tests load result: false."); } var t = testRunner.Test; testRunner.Unload(); return t; // } }
public void LoadTestsFromCompiledAssembly() { CompilerResults results = compiler.CompileCode( goodCode ); Assert.AreEqual( 0, results.NativeCompilerReturnValue ); TestRunner runner = new SimpleTestRunner(); try { Assert.IsTrue( runner.Load( new TestPackage( outputName ) ) ); Assert.AreEqual( 2, runner.Test.TestCount ); } finally { runner.Unload(); } }
private object RunTests(ITestFilter filter) { if (runner != null && runner.Running) { while (runner.Running) { /*do nothing*/ } return GetTestResult(testResults); } using (runner = new SimpleTestRunner()) { runner.Load(package); if (runner.Test == null) { runner.Unload(); return new {text = "Unable to load the tests", status = "warning"}; } TestResult result; try { result = runner.Run(this, filter, true, LoggingThreshold.All); } catch (Exception e) { return new {text = e.Message, status = "error"}; } return result == null ? new {text = "No results", status = "warning"} : GetTestResult(testResults); } }