public ReplayCommand(IMethodInfo method, MethodResult result) : base(method, null, 0) { this.result = result; }
public static void AsyncVoidStepThrowsException(Type feature, MethodResult[] results) { "Given a feature with a scenario that throws an invalid operation exception"._(() => feature = typeof(AsyncVoidStepWhichThrowsException)); "When the test runner runs the feature"._(() => results = TestRunner.Run(feature).ToArray()); "Then the result should be a failure"._(() => results.Should().ContainItemsAssignableTo<FailedResult>()); "And the exception should be an invalid operation exception".And(() => results.Cast<FailedResult>().First().ExceptionType.Should().Be("System.InvalidOperationException")); }
public static void AsyncStepExceedsTimeout(Type feature, MethodResult[] results) { "Given a feature with a scenario with a single step which exceeds it's 1ms timeout"._(() => feature = typeof(AsyncStepWhichExceedsTimeout)); "When the test runner runs the feature"._(() => results = TestRunner.Run(feature).ToArray()); "Then there should be one result"._(() => results.Count().Should().Be(1)); "And the result should be a failure"._(() => results.Should().ContainItemsAssignableTo<FailedResult>()); "And the result message should be \"Test execution time exceeded: 1ms\""._(() => results.Cast<FailedResult>().Should().OnlyContain(result => result.Message == "Test execution time exceeded: 1ms")); }
public static ClassResult Execute(ITestClassCommand testClassCommand, List <IMethodInfo> methods, Predicate <ITestCommand> startCallback, Predicate <ITestResult> resultCallback) { if (methods == null) { methods = new List <IMethodInfo>(); } if (methods.Count == 0) { foreach (IMethodInfo method in testClassCommand.EnumerateTestMethods()) { methods.Add(method); } } ClassResult classResult = new ClassResult(testClassCommand.TypeUnderTest.Type); Exception fixtureException = testClassCommand.ClassStart(); bool @continue = true; if (fixtureException == null) { List <IMethodInfo> runList = new List <IMethodInfo>(); foreach (IMethodInfo method in testClassCommand.EnumerateTestMethods()) { runList.Add(method); } while (@continue && runList.Count > 0) { int idx = testClassCommand.ChooseNextTest(runList.AsReadOnly()); IMethodInfo method = runList[idx]; if (methods.Contains(method)) { foreach (ITestCommand command in TestCommandFactory.Make(testClassCommand, method)) { if (startCallback != null) { @continue = startCallback(command); } if (!@continue) { break; } MethodResult methodResult = command.Execute(testClassCommand.ObjectUnderTest); classResult.Add(methodResult); if (resultCallback != null) { @continue = resultCallback(methodResult); } if (!@continue) { break; } } } runList.RemoveAt(idx); } } classResult.SetException(testClassCommand.ClassFinish() ?? fixtureException); if (resultCallback != null) { resultCallback(classResult); } return(classResult); }