public TestContextStep Establish(IFixtureContext context, TestContextStep next) { return (test, r) => { before(test); test.Timed(_ => next(test, r), after); }; }
private void HandleErrors(TestContextStep tc) { var tcException = tc.Exception; var methodName = tc.Name; var methodParameters = tc.Parameters; if (tcException.NotNull()) { var innerExMessage = tcException.InnerException != null ? "\nInnerException summary: " + tcException.AsString() : ""; var exMsg = "Exception was throws while executing method \'{0}\' with parameters [{1}]. {2}" .AsFormat(methodName, methodParameters, innerExMessage); throw new AutomationException(exMsg, tcException); } if (tc.ExecutionResult.HasExecutionErrors) { var exeSummary = string.Join("\n\t", tc.ExecutionResult.ExecutionSummary()); var exMsg = "FAILURE while executing method \'{0}\' with parameters [{1}]. \nEXECUTION SUMMERY:\n{2}" .AsFormat(methodName, methodParameters, exeSummary); throw new AutomationException(exMsg); } if (tc.ExecutionResult.HasValidationErrors) { var validSummary = string.Join("\n\t", tc.ExecutionResult.ValidationSummary()); var exMsg = "FAILURE while validating method \'{0}\' with parameters [{1}]. \nVALIDATION SUMMERY:\n{2}" .AsFormat(methodName, methodParameters, validSummary); throw new AutomationException(exMsg); } }
public TestContextStep Establish(IFixtureContext context, TestContextStep next) { var pending = FirstPendingOrDefault(context.Attributes, FirstPendingOrDefault(context.Fixture.FixtureType.AsConeAttributeProvider(), null)); return (pending == null) ? Runnable(next) : Pending(next, pending.Reason); }
internal static TestContextStep CreateTestContextStep(TestContext testContext, object[] parameters, MethodInfo methodInfo) { var tcs = new TestContextStep(testContext, methodInfo, parameters); testContext.TestContextSteps.Add(tcs); EventPublisher.Publish(new OnTestContextStepCreatedEvent(tcs)); return(tcs); }
internal static TestContextStepPart CreateTestContextStepPart(TestContextStep step, MethodInfo methodInfo, IEnumerable <object> parameters) { var tcsp = new TestContextStepPart(step, methodInfo, parameters); step.TestContextStepParts.Add(tcsp); EventPublisher.Publish(new OnTestContextStepPartCreatedEvent(tcsp)); return(tcsp); }
TestContextStep Runnable(TestContextStep next) { return (test, result) => { try { next(test, result); } catch(Exception ex) { result.TestFailure(ex); } }; }
public TestContextStep Establish(IFixtureContext context, TestContextStep next) { return (test, result) => { try { if(Before(result)) next(test, result); } finally { After(result); } }; }
TestContextStep Pending(TestContextStep next, string reason) { return (test, result) => { try { next(test, result); result.TestFailure(new CheckFailed("Test passed")); } catch { result.Pending(reason); } }; }
public TestContextStep Establish(IFixtureContext context, TestContextStep next) { var fixture = context.Fixture; return (test, result) => { try { fixture.Before(); } catch(Exception ex) { result.BeforeFailure(ex); return; } next(test, result); }; }
public TestContextStep Establish(IFixtureContext context, TestContextStep next) { var fixture = context.Fixture; return (test, result) => { try { next(test, result); } finally { try { fixture.After(result); } catch (Exception ex) { result.AfterFailure(ex); } } }; }
public void TestContextStep_Create() { if (TestSuiteContext.Instance == null) { TestSuiteContext.Create(); } var parameters = new object[] { "this is params", "wer" }; var mi = this.GetType().GetMethod("TestContextStep_Create"); var tc = new Framework.Testing.TestContext(mi, parameters, null, TestSuiteContext.Instance); var tcs = new TestContextStep(tc, mi, parameters); var part = new TestContextStepPart(tcs, mi, parameters); part.Name.ShouldBe(mi.Name); part.TestContextStep.ShouldBe(tcs); part.Parameters.ShouldBe(parameters); part.ExecutionId.IsNullOrEmpty().ShouldBeFalse(); part.CreatedOnUtc.ShouldNotBe(default(DateTime)); }
public void TestContextStep_Create() { if (TestSuiteContext.Instance == null) { TestSuiteContext.Create(); } var parameters = new[] { "invocationParams" }; var mi = GetType().GetMethod("TestContextStep_Create"); var tc = new TestContext(mi, parameters, null, TestSuiteContext.Instance); var tcs = new TestContextStep(tc, mi, parameters); tcs.Name.ShouldBe(mi.Name); tcs.Parameters.ShouldBe(parameters); tcs.TestContext.ShouldBe(tc); tcs.ExecutionId.IsNullOrEmpty().ShouldBeFalse(); tcs.CreatedOnUtc.ShouldNotBe(default(DateTime)); }
internal static void DisposeTestContextStep(TestContextStep testContextStep) { testContextStep.DisposedOnUtc = DateTime.UtcNow; EventPublisher.Publish(new OnTestContextStepDisposedEvent(testContextStep)); }
private void EndTestContextStepExecution(TestContextStep step) { TestLifetimePublisher.EndTestContextStepExecution(step); TestLifetimePublisher.DisposeTestContextStep(step); }
public OnTestContextStepCreatedEvent(TestContextStep testContextStep) { TestContextStep = testContextStep; }
public TestContextStep Establish(IFixtureContext context, TestContextStep next) { return next; }
internal static void BeforeStartTestContextStepExecution(TestContextStep testContextStep) { EventPublisher.Publish(new OnBeforeTestContextStepExecutionStartEvent(testContextStep)); }
public OnTestContextStepDisposedEvent(TestContextStep testContextStep) { TestContextStep = testContextStep; }
public OnTestContextStepExecutionEndEvent(TestContextStep testContextStep) { TestContextStep = testContextStep; }
public OnBeforeTestContextStepExecutionStartEvent(TestContextStep testContextStep) { TestContextStep = testContextStep; }
internal static void EndTestContextStepExecution(TestContextStep testContextStep) { testContextStep.ExecutionEndedOnUtc = DateTime.UtcNow; EventPublisher.Publish(new OnTestContextStepExecutionEndEvent(testContextStep)); }