/// <summary> /// Start asynchronous execution of a test. /// </summary> /// <param name="listener">The ITestEventListener to use for this run</param> /// <param name="filter">The TestFilter to use for this run</param> public void Start(ITestEventListener listener, TestFilter filter) { _worker.DoWork += (s, ea) => _result = _runner.Run(listener, filter); _worker.RunWorkerAsync(); }
public void SetResult(TestEngineResult result) { Guard.ArgumentNotNull(result, "result"); Guard.OperationValid(_result == null, "Cannot set the Result of an TestRun more than once"); _result = result; _waitHandle.Set(); }
/// <summary> /// Runs the test in given assembly against the provided source assembly. /// </summary> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="TestResult"/>. /// </returns> public TestResult RunTests(TestRunRequest request) { Uri uri = new Uri(request.TestAssembly.CodeBase); this.localDirectory = Path.GetDirectoryName(uri.LocalPath); this.engine = TestEngineActivator.CreateInstance(null, InternalTraceLevel.Off); var settings = new Dictionary<string, object>(); var runner = new DefaultTestAssemblyRunner(new DefaultTestAssemblyBuilder()); runner.Load(request.TestAssembly, settings); // Convert our own framework XmlNode to a TestEngineResult var package = new TestPackage(this.GetLocalPath(uri.AbsolutePath)); this.engineResult = TestEngineResult.MakeTestRunResult( package, DateTime.Now, new TestEngineResult( runner.Run(TestListener.NULL, NUnit.Framework.Internal.TestFilter.Empty).ToXml(true).OuterXml)); return this.SummaryTransformTest(); }
private TestEngineResult AddMetadata(TestEngineResult input) { input.Add("<settings><setting name=\"Setting1Name\" value=\"Setting1Value\"></setting><setting name=\"Setting2Name\" value=\"Setting2Value\"></setting></settings>"); return input.Aggregate("test-run start-time=\"2015-10-19 02:12:28Z\" end-time=\"2015-10-19 02:12:29Z\" duration=\"0.348616\"", string.Empty, string.Empty); }
/// <summary> /// Loads the assembly that contains tests and run the tests. /// </summary> /// <param name="testAssembly"> /// Assembly that will be containing tests /// </param> private void LoadTestAndRunningAssembly(Assembly testAssembly) { Uri uri = new Uri(testAssembly.CodeBase); this.localDirectory = Path.GetDirectoryName(uri.LocalPath); this.engine = TestEngineActivator.CreateInstance(null, InternalTraceLevel.Off); var settings = new Dictionary<string, object>(); var runner = new DefaultTestAssemblyRunner(new DefaultTestAssemblyBuilder()); Assert.True(runner.Load(testAssembly, settings), "Unable to load Executing Assembly."); // Convert our own framework XmlNode to a TestEngineResult var package = new TestPackage(this.GetLocalPath(uri.AbsolutePath)); this.engineResult = TestEngineResult.MakeTestRunResult( package, DateTime.Now, new TestEngineResult( runner.Run(TestListener.NULL, NUnit.Framework.Internal.TestFilter.Empty).ToXml(true).OuterXml)); }