/// <inheritdoc/> public virtual TestRunnerResult RunAssembly(IEnumerable <IResultXmlTransform> transforms) { XmlNode assemblyNode = null; logger.AssemblyStart(wrapper.AssemblyFilename, wrapper.ConfigFilename, wrapper.XunitVersion); TestRunnerResult result = CatchExceptions(() => { assemblyNode = wrapper.RunAssembly(node => XmlLoggerAdapter.LogNode(node, logger)); return(TestRunnerResult.NoTests); }); if (result == TestRunnerResult.Failed) { return(TestRunnerResult.Failed); } if (assemblyNode == null) { return(TestRunnerResult.NoTests); } string assemblyXml = assemblyNode.OuterXml; foreach (IResultXmlTransform transform in transforms) { transform.Transform(assemblyXml); } return(ParseNodeForTestRunnerResult(assemblyNode)); }
/// <summary> /// Run all or selected tests /// </summary> /// <param name="include">Include pattern</param> /// <returns>All tests passed</returns> private static bool RunTests(string[] include) { if (include == null || include.Length < 1) { Console.WriteLine("Running all benchmarks"); } else { Console.WriteLine("Running benchmarks with pattern: " + include[0]); } Console.WriteLine(); string path = Assembly.GetExecutingAssembly().Location; string resultPath = Path.Combine(Path.GetDirectoryName(path), "Results"); Directory.CreateDirectory(resultPath); TestPackage package = new TestPackage(Assembly.GetExecutingAssembly().Location, include); package.Tracing = true; package.OutputDirectory = resultPath; package.Validate(); TestRunnerResult result = TestRunner.Run(package); return(result.AllTestsPassed); }
public void NullAssemblyReturnsNoTests() { TestableTestRunner runner = TestableTestRunner.CreateForAssembly(null); TestRunnerResult result = runner.RunAssembly(); Assert.Equal(TestRunnerResult.NoTests, result); }
public TestRunnerResult RunAssembly() { InMemoryTransform transform = new InMemoryTransform(); TestRunnerResult result = testRunner.RunAssembly(new[] { transform }); Xml = transform.Xml; return(result); }
public void EmptyAssemblyNodeReturnsNoTests() { const string xml = @"<assembly name='C:\foo\bar.dll' run-date='2008-09-20' run-time='12:34:56' time='0.000' total='0' passed='0' failed='0' skipped='0'/>"; TestableTestRunner runner = TestableTestRunner.CreateForAssembly(xml); TestRunnerResult result = runner.RunAssembly(); Assert.Equal(TestRunnerResult.NoTests, result); }
public void ThrownExceptionSentToLoggerAndFailedIsReturned() { TestableTestRunner runner = TestableTestRunner.CreateForAssembly(); Exception exception = new InvalidOperationException(); runner.Executor.RunTests__CallbackEvent += delegate { throw exception; }; TestRunnerResult result = runner.RunTests(null, null); runner.Logger.Verify(l => l.ExceptionThrown(@"C:\foo\bar.dll", exception)); Assert.Equal(TestRunnerResult.Failed, result); }
public void PassingTestReturnsPassed() { const string xml = @" <class time='1.234' name='ThisIsTheType' total='1' passed='1' failed='0' skipped='0'> <test name='This is the test name' type='ThisIsTheType' method='ThisIsTheMethod' result='Pass' time='1.234' /> </class>"; TestableTestRunner runner = TestableTestRunner.CreateForTests(xml); TestRunnerResult result = runner.RunTests(null, null); Assert.Equal(TestRunnerResult.Passed, result); }
public static TestRunState Map(TestRunnerResult result) { switch (result) { case TestRunnerResult.Passed: return TestRunState.Success; case TestRunnerResult.Failed: return TestRunState.Failure; default: return TestRunState.NoTests; } }
public static TestRunState Map(TestRunnerResult result) { switch (result) { case TestRunnerResult.Passed: return(TestRunState.Success); case TestRunnerResult.Failed: return(TestRunState.Failure); default: return(TestRunState.NoTests); } }
public void PassingAssemblyReturnsPassed() { const string xml = @" <assembly name='C:\foo\bar.dll' run-date='2008-09-20' run-time='12:34:56' time='0.000' total='1' passed='1' failed='0' skipped='0'> <class time='1.234' name='ThisIsTheType' total='1' passed='1' failed='0' skipped='0'> <test name='This is the test name' type='ThisIsTheType' method='ThisIsTheMethod' result='Pass' time='1.234' /> </class> </assembly>"; TestableTestRunner runner = TestableTestRunner.CreateForAssembly(xml); TestRunnerResult result = runner.RunAssembly(); Assert.Equal(TestRunnerResult.Passed, result); }
public void ClassFailureReturnsFailed() { const string xml = @" <class time='1.234' name='Class.Name' total='1' passed='0' failed='1' skipped='0'> <failure exception-type='Exception.Type'> <message><![CDATA[Failure message]]></message> <stack-trace><![CDATA[Stack trace]]></stack-trace> </failure> </class>"; TestableTestRunner runner = TestableTestRunner.CreateForTests(xml); TestRunnerResult result = runner.RunTests(null, null); Assert.Equal(TestRunnerResult.Failed, result); }
public void SkippedTestReturnsPassed() { const string xml = @" <class time='1.234' name='ThisIsTheType' total='1' passed='0' failed='0' skipped='1'> <test name='This is the test name' type='ThisIsTheType' method='ThisIsTheMethod' result='Skip'> <reason> <message><![CDATA[Skip reason]]></message> </reason> </test> </class>"; TestableTestRunner runner = TestableTestRunner.CreateForTests(xml); TestRunnerResult result = runner.RunTests(null, null); Assert.Equal(TestRunnerResult.Passed, result); }
public void FailingTestReturnsFailed() { const string xml = @" <class time='1.234' name='ThisIsTheType' total='1' passed='0' failed='1' skipped='0'> <test name='This is the test name' type='ThisIsTheType' method='ThisIsTheMethod' result='Fail' time='1.234'> <failure exception-type='Exception.Type'> <message><![CDATA[Failure message]]></message> <stack-trace><![CDATA[Stack trace]]></stack-trace> </failure> </test> </class>"; TestableTestRunner runner = TestableTestRunner.CreateForTests(xml); TestRunnerResult result = runner.RunTests(null, null); Assert.Equal(TestRunnerResult.Failed, result); }
public void FailingAssemblyReturnsFailed() { const string xml = @" <assembly name='C:\foo\bar.dll' run-date='2008-09-20' run-time='12:34:56' time='0.000' total='1' passed='0' failed='1' skipped='0'> <class time='1.234' name='ThisIsTheType' total='1' passed='0' failed='1' skipped='0'> <test name='This is the test name' type='ThisIsTheType' method='ThisIsTheMethod' result='Fail' time='1.234'> <failure exception-type='Exception.Type'> <message><![CDATA[Failure message]]></message> <stack-trace><![CDATA[Stack trace]]></stack-trace> </failure> </test> </class> </assembly>"; TestableTestRunner runner = TestableTestRunner.CreateForAssembly(xml); TestRunnerResult result = runner.RunAssembly(); Assert.Equal(TestRunnerResult.Failed, result); }
public static TestRunState RunAssembly(TestRunner runner) { TestRunnerResult result = runner.RunAssembly(); return(TestResultMapper.Map(result)); }
public static TestRunState RunMethod(TestRunner runner, MethodInfo method) { TestRunnerResult result = runner.RunTest(method.ReflectedType.FullName, method.Name); return(TestResultMapper.Map(result)); }