public void TestCenter_TestResult_PropertyLinkedWorkItemsForTestResultShouldBeList() { var testRun = _testManagement.TestRuns.Create(); testRun.AddTest(_testCase.Id, _testConfiguration.Id, _testManagement.TfsIdentityStore.FindByAccountName("Administrator")); testRun.Save(); var testResult = testRun.QueryResults()[0]; var iteration = testResult.CreateIteration(1); testResult.Iterations.Add(iteration); // note that these are shuffled var sharedStepResult = iteration.CreateSharedStepResult(_testCase.Actions[2].Id, _sharedStep.Id); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[0].Id)); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[1].Id)); iteration.Actions.Add(sharedStepResult); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[0].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[3].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[1].Id)); testRun.Save(); var testCaseWrapper = new TfsTestResult(testResult, _testCase.Id); var testCaseDetail = new TfsTestResultDetail(testCaseWrapper, testCaseWrapper.OriginalTestResult.TestRunId); Assert.AreEqual(typeof(List <WorkItem>), testCaseDetail.LinkedWorkItemsForTestResult.GetType()); }
public void TestCenter_CustomObjects_ShouldContainCustomPropertyWorkItemsForTestResult() { var testRun = _testManagement.TestRuns.Create(); testRun.AddTest(_testCase.Id, _testConfiguration.Id, _testManagement.TfsIdentityStore.FindByAccountName("Administrator")); testRun.Save(); var testResult = testRun.QueryResults()[0]; var iteration = testResult.CreateIteration(1); testResult.Iterations.Add(iteration); testRun.Save(); var testCaseWrapper = new TfsTestResult(testResult, _testCase.Id); var testCaseDetail = new TfsTestResultDetail(testCaseWrapper, testCaseWrapper.OriginalTestResult.TestRunId); var testInt = 2; testCaseDetail.AddCustomObjects("ASampleProperty", testInt); Assert.AreEqual("2", testCaseDetail.PropertyValue("ASampleProperty", x => x)); Assert.AreEqual("2", testCaseDetail.PropertyValue("ASampleProperty.ToString()", x => x)); }
public void TestCenter_TestActionResult_ShouldInsertIterationVariablesIntoParameterWithSpecialChars() { var testRun = _testManagement.TestRuns.Create(); testRun.AddTest(_testCase.Id, _testConfiguration.Id, _testManagement.TfsIdentityStore.FindByAccountName("Administrator")); testRun.Save(); var testResult = testRun.QueryResults()[0]; var iteration = testResult.CreateIteration(1); testResult.Iterations.Add(iteration); // note that these are shuffled var sharedStepResult = iteration.CreateSharedStepResult(_testCase.Actions[2].Id, _sharedStep.Id); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[0].Id)); var sharedStepActionResult2 = iteration.CreateStepResult(_sharedStep.Actions[1].Id); sharedStepActionResult2.Parameters.Add("ParametersDontLikeSpecialChars", "ShouldWorkDespiteSpecialChar", "MyActualValue"); sharedStepResult.Actions.Add(sharedStepActionResult2); iteration.Actions.Add(sharedStepResult); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[0].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[1].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[3].Id)); testRun.Save(); var testCaseWrapper = new TfsTestResult(testResult, _testCase.Id); var testCaseDetail = new TfsTestResultDetail(testCaseWrapper, testCaseWrapper.OriginalTestResult.TestRunId); Assert.AreEqual("Second Shared Step .: ShouldWorkDespiteSpecialChar", testCaseDetail.PropertyValue("Iterations[0].Actions[3].Title", x => x)); }
public void TestCenter_TestActionResult_ShouldInsertIterationVariablesIntoParameter() { var testRun = _testManagement.TestRuns.Create(); testRun.AddTest(_testCase.Id, _testConfiguration.Id, _testManagement.TfsIdentityStore.FindByAccountName("Administrator")); testRun.Save(); var testResult = testRun.QueryResults()[0]; var iteration = testResult.CreateIteration(1); testResult.Iterations.Add(iteration); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[0].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[1].Id)); var sharedStepResult = iteration.CreateSharedStepResult(_testCase.Actions[2].Id, _sharedStep.Id); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[0].Id)); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[1].Id)); iteration.Actions.Add(sharedStepResult); var testStepResult = iteration.CreateStepResult(_testCase.Actions[3].Id); testStepResult.Parameters.Add("DescriptionParameter", "MyExpectedDescriptionValue", "MyActualValue"); testStepResult.Parameters.Add("ExpectedResultParameter", "MyExpectedResultValue", "MyActualValue"); iteration.Actions.Add(testStepResult); testRun.Save(); var testCaseWrapper = new TfsTestResult(testResult, _testCase.Id); var testCaseDetail = new TfsTestResultDetail(testCaseWrapper, testCaseWrapper.OriginalTestResult.TestRunId); Assert.AreEqual("MyExpectedDescriptionValue", testCaseDetail.PropertyValue("Iterations[0].Actions[4].Title", x => x)); Assert.AreEqual("MyExpectedResultValue", testCaseDetail.PropertyValue("Iterations[0].Actions[4].ExpectedResult", x => x)); }
public void TestCenter_TestActionResult_ShouldAssignStepNumbersAsDefinedInTestCase() { var testRun = _testManagement.TestRuns.Create(); testRun.AddTest(_testCase.Id, _testConfiguration.Id, _testManagement.TfsIdentityStore.FindByAccountName("Administrator")); testRun.Save(); var testResult = testRun.QueryResults()[0]; var iteration = testResult.CreateIteration(1); testResult.Iterations.Add(iteration); // note that these are shuffled var sharedStepResult = iteration.CreateSharedStepResult(_testCase.Actions[2].Id, _sharedStep.Id); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[0].Id)); sharedStepResult.Actions.Add(iteration.CreateStepResult(_sharedStep.Actions[1].Id)); iteration.Actions.Add(sharedStepResult); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[0].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[3].Id)); iteration.Actions.Add(iteration.CreateStepResult(_testCase.Actions[1].Id)); testRun.Save(); var testCaseWrapper = new TfsTestResult(testResult, _testCase.Id); var testCaseDetail = new TfsTestResultDetail(testCaseWrapper, testCaseWrapper.OriginalTestResult.TestRunId); Assert.AreEqual("3.2", testCaseDetail.PropertyValue("Iterations[0].Actions[3].StepNumber", x => x)); }
public static string FindExceptionName(TfsTestResult testResult) { var retVal = ""; if ("JUnit".Equals(testResult.AutomatedTestType)) { var input = testResult.StackTrace; if (!string.IsNullOrEmpty(input) && input.IndexOf(":", StringComparison.Ordinal) > 0) { retVal = input.Substring(0, input.IndexOf(":", StringComparison.Ordinal)); } } if ("UnitTest".Equals(testResult.AutomatedTestType)) { var input = testResult.ErrorMessage; bool found = false; //case1 : error message : Assert.AreEqual failed. Expected:<5>. Actual:<6>. 5 should be equal to 6 if (input.StartsWith("Assert.")) { int endIndex = input.IndexOf(" "); if (endIndex > -1) { retVal = input.Substring(0, endIndex); found = true; } } //case2 : error message : Test method UnitTestProject1.UnitTest1.TestMethod3 threw exception: System.InvalidOperationException: not allowed operation if (!found) { string msgToFind = "threw exception: "; int exceptionStartIndex = input.IndexOf(msgToFind); if (exceptionStartIndex > -1) { int startIndex = exceptionStartIndex + msgToFind.Length; int endIndex = input.IndexOf(":", startIndex); if (endIndex > -1) { retVal = input.Substring(startIndex, endIndex - startIndex).Trim(); found = true; } } } } return(retVal); }
public void TestCenter_TestActionResult_ShouldProvideTestNumberProperty() { var testRun = _testManagement.TestRuns.Create(); testRun.AddTest(_testCase.Id, _testConfiguration.Id, _testManagement.TfsIdentityStore.FindByAccountName("Administrator")); testRun.Save(); var testResult = testRun.QueryResults()[0]; var iteration = testResult.CreateIteration(1); testResult.Iterations.Add(iteration); var stepResult = iteration.CreateStepResult(_testCase.Actions[0].Id); iteration.Actions.Add(stepResult); testRun.Save(); var testCaseWrapper = new TfsTestResult(testResult, _testCase.Id); var testCaseDetail = new TfsTestResultDetail(testCaseWrapper, testCaseWrapper.OriginalTestResult.TestRunId); Assert.AreEqual("1", testCaseDetail.PropertyValue("Iterations[0].Actions[0].StepNumber", x => x)); }