public TestResult MapToTestResult(ExecutedExample example, Test test) { var testResult = new TestResult(test) { DisplayName = BeautifyForDisplay(example.FullName), ErrorMessage = example.ExceptionMessage, ErrorStackTrace = example.ExceptionStackTrace, Duration = example.Duration, ComputerName = Environment.MachineName, }; if (example.Pending) { testResult.Outcome = TestOutcome.Skipped; } else if (example.Failed) { testResult.Outcome = TestOutcome.Failed; } else { testResult.Outcome = TestOutcome.Passed; } return(testResult); }
public override void before_each() { base.before_each(); var someExample = new ExecutedExample() { FullName = "nspec. some context. some passing example.", Pending = false, Failed = false, }; var someTestCase = new TestCase(someExample.FullName, new Uri("http://www.example.com"), somePath); someTestResult = new TestResult(someTestCase) { Outcome = TestOutcome.Failed, }; var testResultMapper = autoSubstitute.Resolve <ITestResultMapper>(); testResultMapper.FromExecutedExample(someExample, somePath).Returns(someTestResult); recorder.BinaryPath = somePath; recorder.RecordExecutedExample(someExample); }
public override void before_each() { base.before_each(); var someContext = new Context("some context"); Action someAction = () => { }; var someExample = new Example("some-example-name", "some-tag another-tag", someAction, false) { Context = someContext, HasRun = true, Exception = new DummyTestException(), }; someExecutedExample = new ExecutedExample() { FullName = someExample.FullName(), Failed = true, ExceptionMessage = someExample.Exception.Message, ExceptionStackTrace = someExample.Exception.StackTrace, }; executedExampleMapper.FromExample(someExample).Returns(someExecutedExample); reporter.Write(someExample, someLevel); }
public void it_should_map_failed_example() { var someError = new DummyTestException(); var someExample = new ExecutedExample() { FullName = "nspec. some context. some failing example.", Pending = false, Failed = true, ExceptionMessage = someError.Message, ExceptionStackTrace = someError.StackTrace, }; var someTestCase = BuildTestCase(someExample); var expected = new TestResult(someTestCase) { Outcome = TestOutcome.Failed, ErrorMessage = someError.Message, ErrorStackTrace = someError.StackTrace, }; var actual = mapper.FromExecutedExample(someExample, somePath); actual.ShouldBeEquivalentTo(expected, TestResultMatchingOptions); }
public void ExampleCompleted(ExecutedExample example) { var test = startedTestMap[example.FullName]; var testResult = exampleMapper.MapToTestResult(example, test); connection.TestFinished(testResult); }
public ExecutedExample FromExample(ExampleBase example) { var executed = new ExecutedExample() { FullName = example.FullName(), Pending = example.Pending, Failed = example.Failed(), }; if (example.Exception != null) { executed.ExceptionMessage = example.Exception.Message; executed.ExceptionStackTrace = example.Exception.StackTrace; } return(executed); }
public void it_should_map_passed_example() { var someExample = new Example("some passed example", tagText, someAction, false) { Context = someContext, HasRun = true, }; var expected = new ExecutedExample() { FullName = someExample.FullName(), }; var actual = mapper.FromExample(someExample); actual.ShouldBeEquivalentTo(expected); }
public void it_should_map_pending_example() { var someExample = new ExecutedExample() { FullName = "nspec. some context. some pending example.", Pending = true, Failed = false, }; var someTestCase = BuildTestCase(someExample); var expected = new TestResult(someTestCase) { Outcome = TestOutcome.Skipped, }; var actual = mapper.FromExecutedExample(someExample, somePath); actual.ShouldBeEquivalentTo(expected, TestResultMatchingOptions); }
public TestResult FromExecutedExample(ExecutedExample executedExample, string binaryPath) { var testCase = new TestCase(executedExample.FullName, Constants.ExecutorUri, binaryPath); var testResult = new TestResult(testCase); if (executedExample.Pending) { testResult.Outcome = TestOutcome.Skipped; } else if (executedExample.Failed) { testResult.Outcome = TestOutcome.Failed; testResult.ErrorMessage = executedExample.ExceptionMessage; testResult.ErrorStackTrace = executedExample.ExceptionStackTrace; } else { testResult.Outcome = TestOutcome.Passed; } return(testResult); }
public void it_should_map_failed_example() { var someError = new DummyTestException(); var someExample = new Example("some failed example", tagText, someAction, false) { Context = someContext, HasRun = true, Exception = someError, }; var expected = new ExecutedExample() { FullName = someExample.FullName(), Failed = true, ExceptionMessage = someError.Message, ExceptionStackTrace = someError.StackTrace, }; var actual = mapper.FromExample(someExample); actual.ShouldBeEquivalentTo(expected); }
void OnExecuted(ExecutedExample example) { actualExecutedExamples.Add(example); }
TestCase BuildTestCase(ExecutedExample someExample) { return(new TestCase(someExample.FullName, Constants.ExecutorUri, somePath)); }