internal TestRunGetter(TfsBase tfsBase) { _tfsBase = tfsBase; }
private TestRun GetTests(int testplanId, bool takeAutomatedTests, string state, params int[] onlyForIds) { var cachedSuiteNames = new Dictionary<int, string>(); var allTestPoints = _tfsBase.GetAllTestPointsInPlan(testplanId, onlyForIds); var caseVsPoints = new Dictionary<int, Test>(); foreach (var point in allTestPoints) { var testCaseId = point.TestCaseId; var testCase = point.TestCaseWorkItem; var automationStatus = testCase.CustomFields.TryGetById(10030); if (testCase.State != state) continue; var isAutomatedTest = automationStatus != null && automationStatus.Value.Equals("Planned"); if (isAutomatedTest) { if (!takeAutomatedTests) continue; } else { if (takeAutomatedTests) continue; } string serviceName = TfsBase.GetCustomFieldValue(testCase, "Service"); string environment = _tfsBase.GetEnvironment(testCase, point.SuiteId, ref cachedSuiteNames); var testSteps = CreateTestStepsIds(testCase.Actions, testCaseId, environment); var testDataCollection = GetIterationDataCollection(testCase); if (testDataCollection == null || testDataCollection.Count == 0) testDataCollection = new List<TestData> {new TestData()}; int testDataCount = 0; foreach (var testData in testDataCollection) { if (!caseVsPoints.ContainsKey(testCaseId)) { caseVsPoints.Add(testCaseId, new Test(testCase.Id, testCase.Title, testCase.State, testCase.WorkItem.Tags)); } var cpyTestSteps = testSteps.Select(x => new TestStep { IsSharedStep = x.IsSharedStep, ParentId = x.ParentId, ParentName = x.ParentName, Result = null, StepId = x.StepId, Description = GetDescription(testData, x), StepIndex = x.StepIndex, ExpectedResult = GetExpectedResult(testData, x) }).ToList(); caseVsPoints[testCaseId].Points.Add(new Point(point.Id, testData, cpyTestSteps, environment, serviceName, testDataCount)); testDataCount++; } } var listOfTests = caseVsPoints.Values.ToList(); return new TestRun { TfsUri = _tfsBase.Config.TfsUri, ForDeployment = false, NumberOfTests = listOfTests.Count(), TeamProject = _tfsBase.Config.TeamProject, Tests = listOfTests, TestPlanId = testplanId }; }
public TestRunSaver(TfsBase tfsBase, ITestStepResultBlobStore testStepBlobStore) { _tfsBase = tfsBase; _testStepBlobStore = testStepBlobStore; }