/// <summary> /// Adds the assembly loaded into the given <see cref="IExecutorWrapper"/> /// into the environment. /// </summary> /// <param name="executorWrapper">The executor wrapper.</param> /// <returns>The <see cref="TestAssembly"/> which represents the newly /// loaded test assembly.</returns> protected TestAssembly Load(IExecutorWrapper executorWrapper) { Guard.ArgumentNotNull("executorWrapper", executorWrapper); TestAssembly testAssembly = TestAssemblyBuilder.Build(executorWrapper); testAssemblies.Add(testAssembly); return(testAssembly); }
/// <summary> /// Initializes a new instance of the <see cref="TestAssembly"/> class. /// </summary> /// <param name="executorWrapper">The executor wrapper.</param> /// <param name="testClasses">The test classes.</param> public TestAssembly(IExecutorWrapper executorWrapper, IEnumerable<TestClass> testClasses) { Guard.ArgumentNotNull("executorWrapper", executorWrapper); Guard.ArgumentNotNull("testClasses", testClasses); ExecutorWrapper = executorWrapper; this.testClasses = testClasses; foreach (TestClass testClass in testClasses) testClass.TestAssembly = this; }
/// <summary> /// Initializes a new instance of the <see cref="TestAssembly"/> class. /// </summary> /// <param name="executorWrapper">The executor wrapper.</param> /// <param name="testClasses">The test classes.</param> public TestAssembly(IExecutorWrapper executorWrapper, IEnumerable <TestClass> testClasses) { Guard.ArgumentNotNull("executorWrapper", executorWrapper); Guard.ArgumentNotNull("testClasses", testClasses); ExecutorWrapper = executorWrapper; this.testClasses = testClasses; foreach (TestClass testClass in testClasses) { testClass.TestAssembly = this; } }
/// <summary> /// Creates a <see cref="TestAssembly"/> which is a complete object model over /// the tests inside of instance of <see cref="IExecutorWrapper"/>. /// </summary> /// <param name="executorWrapper">The executor wrapper</param> /// <returns>The fully populated object model</returns> public static TestAssembly Build(IExecutorWrapper executorWrapper) { List <TestClass> classes = new List <TestClass>(); foreach (XmlNode classNode in executorWrapper.EnumerateTests().SelectNodes("//class")) { List <TestMethod> methods = new List <TestMethod>(); string typeName = classNode.Attributes["name"].Value; foreach (XmlNode testNode in classNode.SelectNodes("method")) { string methodName = testNode.Attributes["method"].Value; string displayName = null; string skipReason = null; if (testNode.Attributes["name"] != null) { displayName = testNode.Attributes["name"].Value; } if (testNode.Attributes["skip"] != null) { skipReason = testNode.Attributes["skip"].Value; } var traits = new MultiValueDictionary <string, string>(); foreach (XmlNode traitNode in testNode.SelectNodes("traits/trait")) { traits.AddValue(traitNode.Attributes["name"].Value, traitNode.Attributes["value"].Value); } TestMethod testMethod = new TestMethod(methodName, displayName ?? typeName + "." + methodName, traits); methods.Add(testMethod); if (!String.IsNullOrEmpty(skipReason)) { testMethod.RunResults.Add(new TestSkippedResult(testMethod.DisplayName, skipReason)); } } classes.Add(new TestClass(typeName, methods)); } return(new TestAssembly(executorWrapper, classes)); }
/// <summary> /// Runs the specified tests in the given type, calling the callback as appropriate. /// This override point exists primarily for unit testing purposes. /// </summary> /// <param name="methods">The test methods to run</param> /// <param name="callback">The run status information callback.</param> protected virtual string RunTests(List <string> methods, ITestMethodRunnerCallback callback) { IRunnerLogger logger = new TestClassCallbackDispatcher(this, callback); IExecutorWrapper wrapper = TestAssembly.ExecutorWrapper; try { XmlNode classNode = wrapper.RunTests(TypeName, methods, node => XmlLoggerAdapter.LogNode(node, logger)); return(classNode.OuterXml); } catch (Exception ex) { logger.ExceptionThrown(wrapper.AssemblyFilename, ex); return(String.Empty); } }
/// <summary> /// Creates a <see cref="TestAssembly"/> which is a complete object model over /// the tests inside of instance of <see cref="IExecutorWrapper"/>. /// </summary> /// <param name="executorWrapper">The executor wrapper</param> /// <returns>The fully populated object model</returns> public static TestAssembly Build(IExecutorWrapper executorWrapper) { Guard.ArgumentNotNull("executorWrapper", executorWrapper); List<TestClass> classes = new List<TestClass>(); foreach (XmlNode classNode in executorWrapper.EnumerateTests().SelectNodes("//class")) { List<TestMethod> methods = new List<TestMethod>(); string typeName = classNode.Attributes["name"].Value; foreach (XmlNode testNode in classNode.SelectNodes("method")) { string methodName = testNode.Attributes["method"].Value; string displayName = null; string skipReason = null; if (testNode.Attributes["name"] != null) displayName = testNode.Attributes["name"].Value; if (testNode.Attributes["skip"] != null) skipReason = testNode.Attributes["skip"].Value; var traits = new MultiValueDictionary<string, string>(); foreach (XmlNode traitNode in testNode.SelectNodes("traits/trait")) traits.AddValue(traitNode.Attributes["name"].Value, traitNode.Attributes["value"].Value); TestMethod testMethod = new TestMethod(methodName, displayName ?? typeName + "." + methodName, traits); methods.Add(testMethod); if (!String.IsNullOrEmpty(skipReason)) testMethod.RunResults.Add(new TestSkippedResult(testMethod.DisplayName, skipReason)); } classes.Add(new TestClass(typeName, methods)); } return new TestAssembly(executorWrapper, classes); }
public static MSVST4U_UnitTestResult ExecuteTest(IExecutorWrapper executor, Guid runId, MSVST4U_UnitTestElement testElement) { var logger = new XUnitTestRunner(runId, testElement); var runner = new TestRunner(executor, logger); string fclassname = MSVST4U_Access.GetFullyQualifiedClassName(testElement); if (fclassname == null) throw new NotImplementedException("xUnit runner does not currently know how to extract a ClassName from test type: " + (testElement == null ? "(null)" : testElement.GetType().FullName)); // The testElement is the original UnitTestElement, so the result is the original UnitTestResult. // However, due to the nature of some unit test types, we could have gathered many results, and must // now group them together. runner.RunTest(fclassname, testElement.Name); MSVST4U_UnitTestResult result; if (logger._isTheory) { Debug.Assert(logger._results.Count > 0, "Expected at least one result for Theory test " + testElement.Name + ": " + logger._results.Count); MSVST4U_UnitTestResult[] innerResults = logger._results.ToArray(); TestOutcome outcome = TestOutcomeHelper.GetAggregationOutcome(innerResults); // for a Theory test (a DataDriven test in the original VS nomenclature), the logger gathered // multiple responses and they should be packed up together in a "TestAggregateResult". Actually, // a original UnitTestResult already implements that and it is available as a constructor overload. result = MSVST4U_Access.New_MSVST4U_UnitTestResult_DataDriven(runId, testElement, outcome, null, innerResults); } else { Debug.Assert(logger._results.Count == 1, "Expected one result for non-Theory test " + testElement.Name + ": " + logger._results.Count); // for a Fact test (a NotDataDriven test in the original VS nomenclature), the logger gathered // a single response; it is completely valid to simply return it result = logger._results[0]; } return result; }
/// <summary> /// Initializes a new instance of the <see cref="TestRunner"/> class. /// </summary> /// <param name="executorWrapper">The executor wrapper.</param> /// <param name="logger">The logger.</param> public TestRunner(IExecutorWrapper executorWrapper, IRunnerLogger logger) { wrapper = executorWrapper; this.logger = logger; }
public StubTestRunner(IExecutorWrapper executor) { this.executor = executor; }
public new TestAssembly Load(IExecutorWrapper executorWrapper) { return base.Load(executorWrapper); }
public XunitTestRun(RemoteTaskServer server, IExecutorWrapper executor, TaskProvider taskProvider) { this.server = server; this.executor = executor; this.taskProvider = taskProvider; }
public XmlTestRunner(IExecutorWrapper executorWrapper, IRunnerLogger logger) { testRunner = new TestRunner(executorWrapper, logger); }
public new TestAssembly Load(IExecutorWrapper executorWrapper) { return(base.Load(executorWrapper)); }
/// <summary> /// Adds the assembly loaded into the given <see cref="IExecutorWrapper"/> /// into the environment. /// </summary> /// <param name="executorWrapper">The executor wrapper.</param> /// <returns>The <see cref="TestAssembly"/> which represents the newly /// loaded test assembly.</returns> protected TestAssembly Load(IExecutorWrapper executorWrapper) { Guard.ArgumentNotNull("executorWrapper", executorWrapper); TestAssembly testAssembly = TestAssemblyBuilder.Build(executorWrapper); testAssemblies.Add(testAssembly); return testAssembly; }