private TestStepState GetOrCreateTestStepStateByTest(MSTest test) { TestStepState testStepState = GetTestStepStateByTest(test); if (testStepState == null) { TestStepState parentTestStepState = GetOrCreateTestStepStateByTest((MSTest)test.Parent); Guid testId = test.Guid; ITestCommand testCommand = GetTestCommandByTestId(testId); TestStep testStep = new TestStep(test, parentTestStepState.TestContext.TestStep, test.Name, test.CodeElement, true); if (test.IsDataDriven) { testStep.IsTestCase = false; } ITestContext testContext = SafeStartCommandStep(parentTestStepState.TestContext, testCommand, testStep); testStepState = new TestStepState(parentTestStepState, testContext); testStepStatesByTest.Add(test, testStepState); testsExecuted.Add(test); } return(testStepState); }
private void FinishTestCommand(ITestCommand testCommand) { FinishTestCommandChildren(testCommand); MSTest test = (MSTest)testCommand.Test; if (test.IsTestCase) { string ignoreReason = test.Metadata.GetValue(MetadataKeys.IgnoreReason); if (!String.IsNullOrEmpty(ignoreReason)) { TestStepState testStepState = GetOrCreateTestStepStateByTest(test); testStepState.TestContext.LogWriter.Warnings.Write(string.Format("Test was ignored: {0}", ignoreReason)); testStepState.Outcome = TestOutcome.Ignored; testStepState.Finish(); } else { TestStepState testStepState = GetTestStepStateByTest(test); if (testStepState == null) { if (!testsExecuted.Contains(test)) { testStepState = GetOrCreateTestStepStateByTest(test); testStepState.TestContext.LogWriter.Warnings.Write("No test results available!"); testStepState.Outcome = TestOutcome.Skipped; testStepState.Finish(); } } else { testStepState.Finish(); } } } else { TestStepState testStepState = GetTestStepStateByTest(test); if (testStepState != null) { testStepState.Finish(); } } }
public void Test() => MSTest.Run();