public List<TestCaseConflict> CreateTestSuites(List<ITestSuite> testSuites, ITestManagementTeamProject selectedProject, IStaticTestSuite staticTestSuite = null, bool throwExceptionIfTestCaseConflicts = true) { List<TestCaseConflict> result = new List<TestCaseConflict>(); ITestSuiteEntryCollection suitcollection = staticTestSuite.Entries; foreach (TestSuite testSuite in testSuites) { if (string.IsNullOrEmpty(testSuite.Name)) { this.CreateTestSuites(testSuite.TestSuites, selectedProject, staticTestSuite, throwExceptionIfTestCaseConflicts); } else { ITestSuiteEntry obj = (from o in suitcollection where string.Compare(o.Title, testSuite.Name, true) == 0 select o).FirstOrDefault() as ITestSuiteEntry; IStaticTestSuite newSuite = (IStaticTestSuite)obj.TestSuite; if (newSuite == null) { newSuite = selectedProject.TestSuites.CreateStatic(); newSuite.Title = testSuite.Name; newSuite.Description = testSuite.Description; suitcollection.Add(newSuite); } result.AddRange(this.CreateTestSuites(testSuite.TestSuites, selectedProject, newSuite, throwExceptionIfTestCaseConflicts)); result.AddRange(this.CreateTestCases(selectedProject, testSuite, newSuite, throwExceptionIfTestCaseConflicts)); } } return result; }
protected void LoadTestPlansForProject() { //Create the list of plans List <string> testPlans = new List <string>(); testPlans.Add(Utils.ALL_TEST_PLANS); //Get the current project name if (this.cboProject.SelectedValue != null) { string projectName = this.cboProject.SelectedValue.ToString(); if (!String.IsNullOrWhiteSpace(projectName)) { //Get the list of plans for this project TfsTeamProjectCollection tfsTeamProjectCollection; TestManagementService testManagementService = GetMtmServiceInstance(out tfsTeamProjectCollection); ITestManagementTeamProject mtmProject = testManagementService.GetTeamProject(projectName); if (mtmProject != null) { ITestPlanCollection plans = mtmProject.TestPlans.Query("Select * From TestPlan"); foreach (ITestPlan mtmTestPlan in plans) { testPlans.Add(mtmTestPlan.Name); } } } } //Set the datasource this.cboTestPlans.DataSource = testPlans; }
private TestResult calculateTestResultByPlans(ITestManagementTeamProject project, ITestPlan testPlan) { var testResult = new TestResult(); testResult.Name = string.Format("{0} - {1}", testPlan.Iteration, testPlan.Name); var testSuites = new List<ITestSuiteBase>(); if (testPlan.RootSuite != null) testSuites.AddRange(GetTestSuiteRecursive(testPlan.RootSuite)); foreach (var testSuite in testSuites) { string queryForTestPointsForSpecificTestSuite = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM TestPoint WHERE SuiteId = {0}", testSuite.Id); var testPoints = testPlan.QueryTestPoints(queryForTestPointsForSpecificTestSuite); foreach (var point in testPoints) { // only get the last result for the current test point // otherwise we would mix test results with different users var result = project .TestResults .ByTestId(point.TestCaseId) .LastOrDefault(testResultToFind => testResultToFind.TestPointId == point.Id); updateTestResultWithOutcome(testResult, result); } } return testResult; }
public void GetTestCasesFromProject() { string interestedFields = "[System.Id], [System.Title]"; // and more //string testCaseName = TestContext.FullyQualifiedTestClassName + "." + TestContext.TestName; //string storageName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase); string query = string.Format("SELECT {0} FROM WorkItems", interestedFields); //TfsConfigurationServer configServer = GetTFSServerInformation(); TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_uri); ITestManagementService testService = tfs.GetService <ITestManagementService>(); //copy the WitDataStore to the bin directory -- https://stackoverflow.com/questions/31031817/unable-to-load-dll-microsoft-witdatastore32-dll-teamfoundation-workitemtracki //http://geekswithblogs.net/BobHardister/archive/2014/09/30/microsoft.witdatastore.dll-not-found-nuget-nuspec-references.aspx //https://stackoverflow.com/questions/28235448/vsto-oneclick-deplyoment-missing-microsoft-witdatastore-dll ITestManagementTeamProject project = testService.GetTeamProject(@"https://tfsqa.mmm.com/tfs/Alderaan/Alderaan Team"); ITestCase foundTestCase = null; IEnumerable <ITestCase> testCases = project.TestCases.Query(query); if (testCases.Count() == 1) { foundTestCase = testCases.First(); } //ITestManagementService tms = configServer.GetService<ITestManagementService>(); //ITestManagementTeamProject teamProject = configServer.GetService<ITestManagementService>().GetTeamProject("Alderaan"); //IEnumerable<ITestCase> testCases = teamProject.TestCases.Query("SELECT * FROM WorkItems"); }
/// <summary> /// Method for processing work items down to the changesets that are related to them /// </summary> /// <param name="wi">Work Item to process</param> /// <param name="outputFile">File to write the dgml to</param> /// <param name="vcs">Version Control Server which contains the changesets</param> public void ProcessWorkItemRelationships(WorkItem[] wi, string outputFile, bool hideReverse, bool groupbyIteration, bool dependencyAnalysis, List<TempLinkType> selectedLinks, VersionControlServer vcs) { string projectName = wi[0].Project.Name; _workItemStubs = new List<WorkItemStub>(); _wis = wi[0].Store; _vcs = vcs; _tms = vcs.TeamProjectCollection.GetService<ITestManagementService>(); _tmp = _tms.GetTeamProject(projectName); _selectedLinks = selectedLinks; //Store options _hideReverse = hideReverse; _groupbyIteration = groupbyIteration; _dependencyAnalysis = dependencyAnalysis; for (int i = 0; i < wi.Length; i++) { ProcessWorkItemCS(wi[i]); } WriteChangesetInfo(outputFile, projectName); }
/// <inheritdoc /> public IDictionary <string, string> GetConfigurationVariables(TfsTestRunProperties runProperties) { if (runProperties == null) { throw new ArgumentNullException("runProperties"); } TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(runProperties.TfsServerCollectionUrl)); teamProjectCollection.Credentials = this.credentials; TestManagementService testService = teamProjectCollection.GetService <TestManagementService>(); ITestManagementTeamProject teamProject = testService.GetTeamProject(runProperties.TeamProject); if (teamProject == null) { throw new InvalidOperationException(String.Format("Failed to find team project named '{0}'", runProperties.TeamProject)); } ITestConfiguration testConfiguration = teamProject.TestConfigurations.Find(runProperties.TestConfigurationId); if (testConfiguration == null) { throw new InvalidOperationException(String.Format("Failed to find test configuration with ID '{0}'. If you're running this tool in a test run managed by VSTS, you make need to upgrade your license for the user executing the test run.", runProperties.TestConfigurationId)); } return(testConfiguration.Values); }
static void Main(string[] args) { TFSTestManager t = new TFSTestManager(); t.KickMe(); //List<String> ret = t.GetTFSCollections(); //ret.Clear(); //ret = t.GetTFSProjects(); //ret.Clear(); //t.GetTestCasesFromProject(); //TFSTestManager t2 = new TFSTestManager(@"https://tfs.mmm.com/tfs"); //ret = t2.GetTFSProjects(); string interestedFields = "[System.Id], [System.Title]"; // and more //string testCaseName = TestContext.FullyQualifiedTestClassName + "." + TestContext.TestName; //string storageName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase); string query = string.Format("SELECT {0} FROM WorkItems", interestedFields); //TfsConfigurationServer configServer = GetTFSServerInformation(); TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(@"https://tfs.mmm.com/tfs")); ITestManagementService testService = (ITestManagementService)tfs.GetService(typeof(ITestManagementService)); ITestManagementTeamProject project = testService.GetTeamProject("Alderaan"); }
private static void FeedTestManagementData(ICollection <TestPlanDefinition> testPlanDefinitionCollection, TfsTeamProjectCollection tpc, string projectName) { ITestManagementService tms = tpc.GetService <ITestManagementService>(); ITestManagementTeamProject tmtp = tms.GetTeamProject(projectName); ITestPlanHelper testPlanHelper = tmtp.TestPlans; ITestPlanCollection testPlanCollection = testPlanHelper.Query("Select * From TestPlan"); foreach (ITestPlan testPlan in testPlanCollection) { TestPlanDefinition testPlanDefinition = new TestPlanDefinition() { Name = testPlan.Name, AreaPath = testPlan.AreaPath, IterationPath = testPlan.Iteration, Description = testPlan.Description, Owner = testPlan.Owner.DisplayName, State = testPlan.State.ToString(), LastUpdate = testPlan.LastUpdated, StartDate = testPlan.StartDate, EndDate = testPlan.EndDate, Revision = testPlan.Revision }; testPlanDefinitionCollection.Add(testPlanDefinition); } }
public static ITestManagementTeamProject GetProject(Uri tfsUri, string projectName, string username, string password) { try { Trace.TraceInformation($"Connecting to VSTS {tfsUri.AbsoluteUri}, Project: {projectName}"); var networkCredential = new NetworkCredential(username, password); BasicAuthCredential basicCred = new BasicAuthCredential(networkCredential); TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred); tfsCred.AllowInteractive = false; TfsTeamProjectCollection projectsCollection = new TfsTeamProjectCollection(tfsUri, tfsCred); ITestManagementService service = (ITestManagementService)projectsCollection.GetService(typeof(ITestManagementService)); ITestManagementTeamProject project = service.GetTeamProject(projectName); Trace.TraceInformation($"project {projectName} found"); return(project); } catch (TestObjectNotFoundException) { Trace.TraceError($"Project {projectName} not found"); return(null); } catch (Exception ex) { Trace.TraceError(ex.Message); return(null); } }
static void Main(string[] args) { string serverUrl = "http://tfs2013:8080/tfs/defaultcollection"; string project = "MyProject"; TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(serverUrl)); ITestManagementService tms = tfs.GetService <ITestManagementService>(); ITestManagementTeamProject proj = tms.GetTeamProject(project); // List all Test Plans foreach (ITestPlan p in proj.TestPlans.Query("Select * From TestPlan")) { Console.WriteLine("------------------------------------------------"); Console.WriteLine("Test Plan - {0} : {1}", p.Id, p.Name); Console.WriteLine("------------------------------------------------"); foreach (ITestSuiteBase suite in p.RootSuite.SubSuites) { Console.WriteLine("\tTest Suite: {0}", suite.Title); IStaticTestSuite staticSuite = suite as IStaticTestSuite; ITestSuiteEntryCollection suiteentrys = suite.TestCases; foreach (ITestSuiteEntry testcase in suiteentrys) { Console.WriteLine("\t\tTest Case - {0} : {1}", testcase.Id, testcase.Title); } Console.WriteLine(""); } Console.WriteLine(""); } }
void BtnConnect_Click(object sender, RoutedEventArgs e) { _tfs = null; TbTfs.Text = null; var tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); tpp.ShowDialog(); if (tpp.SelectedTeamProjectCollection == null) { return; } _tfs = tpp.SelectedTeamProjectCollection; var testService = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService)); _testProject = testService.GetTeamProject(tpp.SelectedProjects[0].Name); TbTfs.Text = _tfs.Name + "\\" + _testProject; _testPlanCollection = _testProject.TestPlans.Query("Select * from TestPlan"); ProjectSelected_GetTestPlans(); btnGenerateXMLFile.IsEnabled = false; }
/// <summary> /// Saves the specified shared step. /// </summary> /// <param name="sharedStep">The shared step.</param> /// <param name="createNew">if set to <c>true</c> [create new].</param> /// <param name="newSuiteTitle">The new suite title.</param> /// <param name="testSteps">The test steps.</param> /// <returns></returns> public static SharedStep Save(this SharedStep sharedStep, ITestManagementTeamProject testManagementTeamProject, bool createNew, ICollection<TestStep> testSteps, bool shouldSetArea = true) { SharedStep currentSharedStep = sharedStep; if (createNew) { ISharedStep sharedStepCore = testManagementTeamProject.SharedSteps.Create(); currentSharedStep = new SharedStep(sharedStepCore); } if (shouldSetArea) { currentSharedStep.ISharedStep.Area = sharedStep.Area; } currentSharedStep.ISharedStep.Title = sharedStep.Title; currentSharedStep.ISharedStep.Priority = (int)sharedStep.Priority; currentSharedStep.ISharedStep.Actions.Clear(); currentSharedStep.ISharedStep.Owner = testManagementTeamProject.TfsIdentityStore.FindByTeamFoundationId(sharedStep.TeamFoundationId); List<Guid> addedSharedStepGuids = new List<Guid>(); foreach (TestStep currentStep in testSteps) { ITestStep testStepCore = currentSharedStep.ISharedStep.CreateTestStep(); testStepCore.Title = currentStep.ActionTitle; testStepCore.ExpectedResult = currentStep.ActionExpectedResult; currentSharedStep.ISharedStep.Actions.Add(testStepCore); } currentSharedStep.ISharedStep.Flush(); currentSharedStep.ISharedStep.Save(); return currentSharedStep; }
public static bool AssociateTestCase(ITestManagementTeamProject project, AutomatedTestMethod testMethod) { try { var automatedTest = project.TestCases.Find(testMethod.TestID); if (automatedTest != null) { automatedTest.SetAssociatedAutomation(project, testMethod); automatedTest.Save(); testMethod.Associated = true; Trace.TraceInformation($"Automated test method {testMethod.FullName} associated to {testMethod.TestID} | {automatedTest.Title}"); return(true); } Trace.TraceWarning($"Test with ID {testMethod.TestID} not found"); return(false); } catch (DeniedOrNotExistException ex) { Trace.TraceWarning(ex.Message); return(false); } catch (Exception ex) { Trace.TraceError(ex.Message); return(false); } }
/// <summary> /// Gets the shared step by unique identifier. /// </summary> /// <param name="sharedStepId">The shared step unique identifier.</param> /// <returns></returns> public static SharedStep GetSharedStepById(ITestManagementTeamProject testManagementTeamProject, int sharedStepId) { ISharedStep sharedStepCore = testManagementTeamProject.SharedSteps.Find(sharedStepId); SharedStep currentSharedStep = new SharedStep(sharedStepCore); return currentSharedStep; }
public TestManagementContext(ITeamProjectContext source, string testPlanQueryBit) { this.testPlanQueryBit = testPlanQueryBit; this.source = source; tms = (ITestManagementService)source.Collection.GetService(typeof(ITestManagementService)); Project = tms.GetTeamProject(source.Name); }
public IList <IReportItem> GetData(ITestManagementTeamProject teamProject, IUriFactory uriFactory, uint testItemID, CancellationToken cancellationToken, IProgress <string> progress) { ReportProgress(progress, $"Looking for test plan with ID {testItemID} ..."); var testPlan = teamProject.TestPlans.Find((int)testItemID); if (testPlan == null) { ReportProgress(progress, $"Test plan with ID {testItemID} not found ..."); Thread.Sleep(500); ReportProgress(progress, $"Trying to find test suite with ID {testItemID} ..."); var testSuite = teamProject.TestSuites.Find((int)testItemID); if (testSuite == null) { ReportProgress(progress, $"Test suite with ID {testItemID} not found ..."); Thread.Sleep(500); return(new List <IReportItem>(0)); } if (!(testSuite is IStaticTestSuite staticTestSuite)) { return(new List <IReportItem>(0)); } return(new List <IReportItem> { LoadTestSuite(teamProject, uriFactory, staticTestSuite, cancellationToken, progress) }); } else { return(new List <IReportItem> { LoadTestPlan(teamProject, uriFactory, testPlan, cancellationToken, progress) }); } }
/** * This will take the TFS Project */ public void setTFSProject() { TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); //Following actions will be executed only if a team project is selected in the the opened dialog. if (tpp.SelectedTeamProjectCollection != null) { this._tfs = tpp.SelectedTeamProjectCollection; ITestManagementService test_service = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService)); //tmService = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService)); _store = (WorkItemStore)_tfs.GetService(typeof(WorkItemStore)); this._teamProject = test_service.GetTeamProject(tpp.SelectedProjects[0].Name); //Call to method "Get_TestPlans" to get the test plans in the selected team project //Get_TestPlans(_teamProject); } else { System.Environment.Exit(1); } }
/// <summary> /// Adds the child suite. /// </summary> /// <param name="parentSuiteId">The parent suite unique identifier.</param> /// <param name="title">The title.</param> /// <param name="canBeAdded">if set to <c>true</c> [can be added].</param> /// <returns> /// new suite unique identifier. /// </returns> public static int AddChildSuite(ITestManagementTeamProject testManagementTeamProject, ITestPlan testPlan, int parentSuiteId, string title, out bool canBeAdded) { ITestSuiteBase parentSuite = null; if (parentSuiteId != -1) { parentSuite = testManagementTeamProject.TestSuites.Find(parentSuiteId); } if (parentSuite is IRequirementTestSuite) { canBeAdded = false; return(0); } IStaticTestSuite staticSuite = testManagementTeamProject.TestSuites.CreateStatic(); canBeAdded = true; staticSuite.Title = title; if (parentSuite != null && parentSuite is IStaticTestSuite && parentSuiteId != -1) { IStaticTestSuite parentSuiteStatic = parentSuite as IStaticTestSuite; parentSuiteStatic.Entries.Add(staticSuite); log.InfoFormat("Add child suite to suite with Title= {0}, Id = {1}, child suite title= {2}", parentSuite.Title, parentSuite.Id, title); } else { testPlan.RootSuite.Entries.Add(staticSuite); log.InfoFormat("Add child suite with title= {0} to test plan", title); } testPlan.Save(); return(staticSuite.Id); }
static void Main(string[] args) { Uri CollectionUri = (args.Length < 1) ? new Uri("http://desktop-anh3ro7:8080/tfs/DefaultCollection/") : new Uri(args[0]); TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(CollectionUri); WorkItemStore wis = tpc.GetService <WorkItemStore>(); // To get work items service ITestManagementTeamProject tm = tpc.GetService <ITestManagementService>().GetTeamProject("TechBrothers"); }
internal static int Add_TestResolutionStates( Excel.XlLocation insertAt, Options_AZDO_TFS options, ITestManagementTeamProject testManagementTeamProject) { Int64 startTicks = Log.APPLICATION("Enter", Common.LOG_CATEGORY); int itemCount = 0; IEnumerable <ITestResolutionState> testResolutionStates = testManagementTeamProject.TestResolutionStates.Query(); int totalItems = testResolutionStates.Count(); XlHlp.DisplayInWatchWindow($"Processing ({ totalItems } testResolutionStates"); foreach (ITestResolutionState testResolutionState in testManagementTeamProject.TestResolutionStates.Query()) { insertAt.ClearOffsets(); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), testManagementTeamProject.TeamProjectName); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testResolutionState.Id}"); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testResolutionState.Name}"); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testResolutionState.Project.TeamProjectName}"); insertAt.IncrementRows(); itemCount++; //ProcessItemDelay(options); AZDOHelper.DisplayLoopUpdates(startTicks, options, totalItems, itemCount); } Log.APPLICATION("Exit", Common.LOG_CATEGORY, startTicks); return(itemCount); }
/// <summary> /// Renames the suite. /// </summary> /// <param name="suiteId">The suite unique identifier.</param> /// <param name="newName">The new name.</param> public static void RenameSuite(ITestManagementTeamProject testManagementTeamProject, ITestPlan testPlan, int suiteId, string newName) { ITestSuiteBase currentSuite = testManagementTeamProject.TestSuites.Find(suiteId); log.InfoFormat("Change Suite title from {0} to {1}, Suite Id = {2}", currentSuite.Title, newName, currentSuite.Id); currentSuite.Title = newName; testPlan.Save(); }
/// <summary> /// Saves the specified shared step. /// </summary> /// <param name="sharedStep">The shared step.</param> /// <param name="createNew">if set to <c>true</c> [create new].</param> /// <param name="newSuiteTitle">The new suite title.</param> /// <param name="testSteps">The test steps.</param> /// <returns></returns> public static SharedStep Save(this SharedStep sharedStep, ITestManagementTeamProject testManagementTeamProject, bool createNew, ICollection <TestStep> testSteps, bool shouldSetArea = true) { SharedStep currentSharedStep = sharedStep; if (createNew) { ISharedStep sharedStepCore = testManagementTeamProject.SharedSteps.Create(); currentSharedStep = new SharedStep(sharedStepCore); } if (shouldSetArea) { currentSharedStep.ISharedStep.Area = sharedStep.Area; } currentSharedStep.ISharedStep.Title = sharedStep.Title; currentSharedStep.ISharedStep.Priority = (int)sharedStep.Priority; currentSharedStep.ISharedStep.Actions.Clear(); currentSharedStep.ISharedStep.Owner = testManagementTeamProject.TfsIdentityStore.FindByTeamFoundationId(sharedStep.TeamFoundationId); List <Guid> addedSharedStepGuids = new List <Guid>(); foreach (TestStep currentStep in testSteps) { ITestStep testStepCore = currentSharedStep.ISharedStep.CreateTestStep(); testStepCore.Title = currentStep.ActionTitle; testStepCore.ExpectedResult = currentStep.ActionExpectedResult; currentSharedStep.ISharedStep.Actions.Add(testStepCore); } currentSharedStep.ISharedStep.Flush(); currentSharedStep.ISharedStep.Save(); return(currentSharedStep); }
private static bool TryGetCoverageInfo(ITestManagementTeamProject testProject, string buildUri, out IBuildCoverage[] coverageInfo) { coverageInfo = testProject.CoverageAnalysisManager.QueryBuildCoverage(buildUri, CoverageQueryFlags.Modules); return(coverageInfo != null && coverageInfo.Length > 0); }
public TestManagementContext(IMigrationClient source, string testPlanQueryBit) { this.testPlanQueryBit = testPlanQueryBit; _source = source; tms = _source.GetService <ITestManagementService>(); Project = tms.GetTeamProject(source.Config.AsTeamProjectConfig().Project); }
/// <summary> /// Gets the shared step by unique identifier. /// </summary> /// <param name="sharedStepId">The shared step unique identifier.</param> /// <returns></returns> public static SharedStep GetSharedStepById(ITestManagementTeamProject testManagementTeamProject, int sharedStepId) { ISharedStep sharedStepCore = testManagementTeamProject.SharedSteps.Find(sharedStepId); SharedStep currentSharedStep = new SharedStep(sharedStepCore); return(currentSharedStep); }
internal static int Add_Queries( Excel.XlLocation insertAt, Options_AZDO_TFS options, ITestManagementTeamProject testManagementTeamProject) { Int64 startTicks = Log.APPLICATION("Enter", Common.LOG_CATEGORY); int itemCount = 0; int totalItems = testManagementTeamProject.Queries.Count; XlHlp.DisplayInWatchWindow($"Processing ({ totalItems } Queries"); foreach (ITestCaseQuery query in testManagementTeamProject.Queries) { insertAt.ClearOffsets(); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), testManagementTeamProject.TeamProjectName); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), query.Name); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), query.Owner); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), query.QueryText); insertAt.IncrementRows(); itemCount++; AZDOHelper.ProcessItemDelay(options); AZDOHelper.DisplayLoopUpdates(startTicks, options, totalItems, itemCount); } Log.APPLICATION("Exit", Common.LOG_CATEGORY, startTicks); return(itemCount); }
/// <summary> /// Loads project settings from registry. /// </summary> public void LoadProjectSettingsFromRegistry(ref TfsTeamProjectCollection tfsTeamProjectCollection, ref ITestManagementTeamProject testManagementTeamProject, ref Preferences preferences, ITestManagementService testService, string selectedTestPlan) { log.Info("Load project info loaded from registry!"); string teamProjectUri = RegistryManager.Instance.GetTeamProjectUri(); string teamProjectName = RegistryManager.Instance.GetTeamProjectName(); string projectDllPath = RegistryManager.Instance.GetProjectDllPath(); if (!string.IsNullOrEmpty(teamProjectUri) && !string.IsNullOrEmpty(teamProjectName)) { preferences.TfsUri = new Uri(teamProjectUri); log.InfoFormat("Registry> TFS URI: {0}", preferences.TfsUri); preferences.TestProjectName = teamProjectName; log.InfoFormat("Registry> Test Project Name: {0}", preferences.TestProjectName); tfsTeamProjectCollection = new TfsTeamProjectCollection(preferences.TfsUri); log.InfoFormat("Registry> TfsTeamProjectCollection: {0}", tfsTeamProjectCollection); testService = (ITestManagementService)tfsTeamProjectCollection.GetService(typeof(ITestManagementService)); testManagementTeamProject = testService.GetTeamProject(preferences.TestProjectName); selectedTestPlan = RegistryManager.Instance.GetTestPlan(); log.InfoFormat("Registry> SelectedTestPlan: {0}", selectedTestPlan); if (!string.IsNullOrEmpty(selectedTestPlan)) { preferences.TestPlan = TestPlanManager.GetTestPlanByName(testManagementTeamProject, selectedTestPlan); this.IsInitializedFromRegistry = true; } } }
private Thread CreateTaskThread() { return(new Thread(() => { while (true) { try { using (new ConsoleFormatter(ConsoleColor.DarkGreen, ConsoleColor.White)) { Console.WriteLine($"Refreshing data at: {DateTime.Now.ToShortTimeString()}"); } lock (handle) { using (TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(context.ApiUrl))) { ITestManagementService service = tfs.GetService(typeof(ITestManagementService)) as ITestManagementService; ITestManagementTeamProject testProject = service.GetTeamProject(context.Project); //Can extract information about the test suite from here ITestSuiteBase testSuite = testProject.TestSuites.Find(context.SuiteId); //This is a given instance of the test suite , I.E the test plan (suites can be re-used) ITestPlan testPlan = testProject.TestPlans.Find(context.PlanId); Console.WriteLine($"Test Suite: {testSuite.Title} \n Description: {testPlan.Description} \n Last Updated: {testPlan.LastUpdated}"); testPlanDataSetFactory.Initialize(testPlan, testProject, context.ApiUrl, context.Project); } } Thread.Sleep(TimeSpan.FromMinutes(context.RefreshTime)); } catch (ThreadInterruptedException) { // This is used as a way to wake up sleeping thread. } } })); }
public TestPlanMigration(string sourceTfsUrl, string targetTfsUrl, string sourceProjectName, string targetProjectName, Dictionary <int, int> workItemMap) { var sourceTfs = Utils.GetTfsTeamProjectCollection(sourceTfsUrl); var destinationTfs = Utils.GetTfsTeamProjectCollection(targetTfsUrl); this.SourceProjectName = sourceProjectName; this.TargetProjectName = targetProjectName; this.sourceTestMgmtProj = GetProject(sourceTfs, sourceProjectName); this.targetTestMgmtProj = GetProject(destinationTfs, targetProjectName); this.WorkItemMap = workItemMap; var targetWorkitemStore = Utils.GetWorkItemStore(targetTfsUrl, true); var sourceWorkitemStore = Utils.GetWorkItemStore(sourceTfsUrl, false); var targetProject = targetWorkitemStore.Projects[targetProjectName]; var sourceProject = sourceWorkitemStore.Projects[sourceProjectName]; this.AreaMap = Utils.GetNodeMap(sourceProject.AreaRootNodes, targetProject.AreaRootNodes); this.AreaMapTitles = new Dictionary <string, string>(); foreach (var kvp in this.AreaMap) { this.AreaMapTitles.Add(sourceProject.FindNodeInSubTree(kvp.Key).Path, targetProject.FindNodeInSubTree(kvp.Value).Path); } this.IterationMap = Utils.GetNodeMap(sourceProject.IterationRootNodes, targetProject.IterationRootNodes); this.IterationMapTitle = new Dictionary <string, string>(); foreach (var kvp in this.IterationMap) { this.IterationMapTitle.Add(sourceProject.FindNodeInSubTree(kvp.Key).Path, targetProject.FindNodeInSubTree(kvp.Value).Path); } }
public static ITestRun CreateTestRun(int testId) { NetworkCredential cred = new NetworkCredential("UserName", "Password"); TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("VSTSSiteBase")); tfs.Credentials = cred; tfs.Authenticate(); tfs.EnsureAuthenticated(); ITestManagementTeamProject project = tfs.GetService <ITestManagementService>().GetTeamProject("Schwans Company"); // find the test case. ITestCase testCase = project.TestCases.Find(testId); string title = testCase.Title.ToString(); // find test plan. int planId = Int32.Parse("testPlanId"); //ConfigurationManager.AppSettings["TestPlanId"]); ITestPlan plan = project.TestPlans.Find(planId); // Create test configuration. You can reuse this instead of creating a new config everytime. ITestConfiguration config = CreateTestConfiguration(project, string.Format("My test config {0}", DateTime.Now)); // Create test points. IList <ITestPoint> testPoints = CreateTestPoints(project, plan, new List <ITestCase>() { testCase }, new IdAndName[] { new IdAndName(config.Id, config.Name) }); // Create test run using test points. ITestRun run = CreateRun(project, plan, testPoints, title); return(run); }
/// <summary> /// Method for processing work items down to the changesets that are related to them /// </summary> /// <param name="wi">Work Item to process</param> /// <param name="outputFile">File to write the dgml to</param> /// <param name="vcs">Version Control Server which contains the changesets</param> public void ProcessWorkItemRelationships(WorkItem[] wi, string outputFile, bool hideReverse, bool groupbyIteration, bool dependencyAnalysis, List <TempLinkType> selectedLinks, VersionControlServer vcs) { string projectName = wi[0].Project.Name; _workItemStubs = new List <WorkItemStub>(); _wis = wi[0].Store; _vcs = vcs; _tms = vcs.TeamProjectCollection.GetService <ITestManagementService>(); _tmp = _tms.GetTeamProject(projectName); _selectedLinks = selectedLinks; //Store options _hideReverse = hideReverse; _groupbyIteration = groupbyIteration; _dependencyAnalysis = dependencyAnalysis; for (int i = 0; i < wi.Length; i++) { ProcessWorkItemCS(wi[i]); } WriteChangesetInfo(outputFile, projectName); }
/// <summary> /// Deletes the suite. /// </summary> /// <param name="suiteToBeRemovedId">The suite to be removed unique identifier.</param> /// <param name="parent">The parent.</param> /// <exception cref="System.ArgumentException">The root suite cannot be deleted!</exception> public static void DeleteSuite(ITestManagementTeamProject testManagementTeamProject, ITestPlan testPlan, int suiteToBeRemovedId, IStaticTestSuite parent = null) { // If it's root suite throw exception if (suiteToBeRemovedId == -1) { throw new ArgumentException("The root suite cannot be deleted!"); } ITestSuiteBase currentSuite = testManagementTeamProject.TestSuites.Find(suiteToBeRemovedId); // Remove the parent child relation. This is the only way to delete the suite. if (parent != null) { log.InfoFormat("Remove suite Title= \"{0}\", id= \"{1}\" from suite Title= \"{2}\", id= \"{3}\"", currentSuite.Title, currentSuite.Id, parent.Title, parent.Id); parent.Entries.Remove(currentSuite); } else if (currentSuite.Parent != null) { log.InfoFormat("Remove suite Title= \"{0}\", id= \"{1}\" from suite Title= \"{2}\", id= \"{3}\"", currentSuite.Title, currentSuite.Id, currentSuite.Parent.Title, currentSuite.Parent.Id); currentSuite.Parent.Entries.Remove(currentSuite); } else { // If it's initial suite, remove it from the test plan. testPlan.RootSuite.Entries.Remove(currentSuite); log.Info("Remove suite Title= \"{0}\", id= \"{1}\" from test plan."); } // Apply changes to the suites testPlan.Save(); }
public WorkItemGenerator(string serverName, string projectName) { if (string.IsNullOrEmpty(serverName)) { throw new ArgumentNullException("serverName", "servername is null"); } if (string.IsNullOrEmpty(projectName)) { throw new ArgumentNullException("projectName", "projectName is null"); } TeamProjectCollection = new TfsTeamProjectCollection(new Uri(serverName), new Services.Common.VssCredentials()); // Get the Test Management Service ITestManagementService service = (ITestManagementService)TeamProjectCollection.GetService(typeof(ITestManagementService)); // Initialize the TestManagement Team Project m_teamProject = (ITestManagementTeamProject)service.GetTeamProject(projectName); ILocationService locationService = TeamProjectCollection.GetService <ILocationService>(); IsTFS2012 = !String.IsNullOrEmpty(locationService.LocationForCurrentConnection("IdentityManagementService2", new Guid("A4CE4577-B38E-49C8-BDB4-B9C53615E0DA"))); // Set the Properties Server = serverName; Project = projectName; SourceNameToFieldMapping = new Dictionary <string, IWorkItemField>(); m_suiteCreater = new TestPlanAndSuiteCreator(m_teamProject); m_areaAndIterationPathCreator = new AreaAndIterationPathCreator(m_teamProject.WitProject); WorkItemCategoryToDefaultType = new Dictionary <string, string>(); LinkTypeNames = new List <string>(); m_workItemLinkTypeEndCollection = m_teamProject.WitProject.Store.WorkItemLinkTypes.LinkTypeEnds; foreach (WorkItemLinkTypeEnd linkTypeEnd in m_teamProject.WitProject.Store.WorkItemLinkTypes.LinkTypeEnds) { string linkTypeName = linkTypeEnd.Name; LinkTypeNames.Add(linkTypeName); } WorkItemTypeToCategoryMapping = new Dictionary <string, string>(); WorkItemTypeNames = new List <string>(); PopulateWorkItemTypeDetailsFromCategory(m_teamProject.WitProject.Categories, BugCategory); PopulateWorkItemTypeDetailsFromCategory(m_teamProject.WitProject.Categories, RequirementCategory); Category testCaseCategory = m_teamProject.WitProject.Categories[TestCaseCategory]; if (testCaseCategory != null) { DefaultWorkItemTypeName = testCaseCategory.DefaultWorkItemType.Name; PopulateWorkItemTypeDetailsFromCategory(m_teamProject.WitProject.Categories, TestCaseCategory); } CreateAreaIterationPath = true; }
private static void ChurnScenarios(string[] arrLine, Feature feature, ITestManagementTeamProject teamProject, ICollection <Tag> tags, string area, IList <TestCaseField> fieldsCollection) { var backgroundSteps = GetBackgroundSteps(arrLine, feature); var iterationStart = backgroundSteps.Any() ? 1 : 0; ScenarioDefinition background = null; if (backgroundSteps.Any()) { background = GetBackground(feature); } var scenarioDefinitions = feature.Children.ToArray(); for (; iterationStart < scenarioDefinitions.Length; iterationStart++) { var scenarioDefinition = scenarioDefinitions[iterationStart]; var scenarioTags = GherkinUtils.GetTags(scenarioDefinition); if (!CanChurnScenario(scenarioDefinition, fieldsCollection)) { continue; } var hash = GetHash(arrLine, scenarioDefinitions, iterationStart, scenarioDefinition, backgroundSteps); var mtmIdTag = scenarioTags.FirstOrDefault( scenarioTag => scenarioTag.Name.Trim().ToUpperInvariant().StartsWith( SyncUtil.MtmTcLink, StringComparison.InvariantCulture)); Logger.Info(ResourceStrings.DECORATION, $"Syncing scenario, {scenarioDefinition.Name}"); if (mtmIdTag == null) { SaveChanges(teamProject, background, null, scenarioDefinition, hash, area, tags, fieldsCollection); continue; } var testCaseId = Regex.Match(mtmIdTag.Name, SyncUtil.MtmTcIdPattern).Groups[1].Value; try { var testCase = teamProject.TestCases.Find(Int32.Parse(testCaseId, CultureInfo.InvariantCulture)); if (testCase != null) { if (UpdateTestCase(testCase, scenarioDefinition, hash, fieldsCollection)) { testCase.Actions.Clear(); SaveChanges(teamProject, background, testCase, scenarioDefinition, hash, area, tags, fieldsCollection); } continue; } } catch (DeniedOrNotExistException) { // This could happen when a test case is deleted from the MTM but exists in the corresponding feature file Logger.Info(ResourceStrings.DECORATION, $"Linked test case, {mtmIdTag.Name}, is not found"); } // Need to create a test case when the link is failed SaveChanges(teamProject, background, null, scenarioDefinition, hash, area, tags, fieldsCollection); } }
private static IStaticTestSuite CreateTestSuite(ITestManagementTeamProject project) { // Create a static test suite. IStaticTestSuite testSuite = project.TestSuites.CreateStatic(); testSuite.Title = "Static Suite"; return(testSuite); }
public TestPlanMigration(TfsTeamProjectCollection sourceTfs, TfsTeamProjectCollection destinationTfs, string sourceProject, string destinationProject, Hashtable workItemMap, ProgressBar progressBar) { this.sourceproj = GetProject(sourceTfs, sourceProject); this.destinationproj = GetProject(destinationTfs, destinationProject); this.workItemMap = workItemMap; this.progressBar = progressBar; projectName = sourceProject; }
public TestPlanMigration(TfsTeamProjectCollection sourceTfs, TfsTeamProjectCollection destinationTfs, string sourceProject, string destinationProject, Hashtable workItemMap, ProgressBar progressBar) { sourceproj = GetProject(sourceTfs, sourceProject); destinationproj = GetProject(destinationTfs, destinationProject); this.workItemMap = workItemMap; this.progressBar = progressBar; projectName = sourceProject; }
private void btnSelectDestinationTfsProject_Click(object sender, EventArgs e) { _destinationTestManagementTeamProject = TfsOperations.SelectTfsProject(true); if (_destinationTestManagementTeamProject != null) { lblDestinationTfsProject.Text = _destinationTestManagementTeamProject.ToString(); } }
private List<WorkItemStub> _workItemStubs; //Stores the distinct list of all work items to be written to the dgml #endregion Fields #region Constructors public ProcessFullAnalysis(WorkItemStore wis, VersionControlServer vcs, string projectName, string outputFile) { _wis = wis; _vcs = vcs; _tms = vcs.TeamProjectCollection.GetService<ITestManagementService>(); _tmp = _tms.GetTeamProject(projectName); _projectName = projectName; _outputFile = outputFile; }
/// <summary> /// Creates the test plan. /// </summary> /// <param name="tfsTeamProjectCollection">The TFS team project collection.</param> /// <param name="testManagementTeamProject">The test management team project.</param> /// <param name="name">The name.</param> /// <returns></returns> public static TestPlan CreateTestPlan(TfsTeamProjectCollection tfsTeamProjectCollection, ITestManagementTeamProject testManagementTeamProject, string name) { ITestPlan newTestPlan = testManagementTeamProject.TestPlans.Create(); newTestPlan.Name = name; newTestPlan.Owner = tfsTeamProjectCollection.AuthorizedIdentity; newTestPlan.Save(); return new TestPlan(newTestPlan); }
public static int CreateNewTestPlan(ITestManagementTeamProject teamProject, string testPlanName) { ITestPlan plan = teamProject.TestPlans.Create(); plan.Name = testPlanName; plan.StartDate = DateTime.Now; plan.EndDate = DateTime.Now.AddMonths(2); plan.Save(); return plan.Id; }
public TestSuiteDialog(ITestManagementTeamProject testProject, TestEditInfo testEditInfo) { _loadBackgroundWorker = new BackgroundWorker(); _testProject = testProject; _testEditInfo = testEditInfo; InitializeComponent(); this.Load += (e, o) => LoadRelatedTestPoints(); }
/// <summary> /// Gets all shared steps information test plan. /// </summary> /// <returns></returns> public static List<SharedStep> GetAllSharedStepsInTestPlan(ITestManagementTeamProject testManagementTeamProject) { List<SharedStep> sharedSteps = new List<SharedStep>(); var testPlanSharedStepsCore = testManagementTeamProject.SharedSteps.Query("SELECT * FROM WorkItems WHERE [System.TeamProject] = @project and [System.WorkItemType] = 'Shared Steps'"); foreach (ISharedStep currentSharedStepCore in testPlanSharedStepsCore) { SharedStep currentSharedStep = new SharedStep(currentSharedStepCore); sharedSteps.Add(currentSharedStep); } return sharedSteps; }
public static int CreateCurrentTestConfiguration(ITestManagementTeamProject teamProject) { ITestConfiguration config = GetTestConfiguration(teamProject, OSInfo.ShortNameWithIE); if (config == null) { config = teamProject.TestConfigurations.Create(); config.Name = OSInfo.ShortNameWithIE; config.Description = OSInfo.FriendlyName + " with " + OSInfo.GetFriendyIEVersionName; config.Values.Add("Operating System", OSInfo.FriendlyName); config.Values.Add("Browser", OSInfo.GetFriendyIEVersionName); config.Save(); } return config.Id; }
/// <summary> /// Method to connect to the TFS project /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void ConnectButton_Click(object sender, RoutedEventArgs e) { TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); var result = tpp.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { this.tfs = tpp.SelectedTeamProjectCollection; this.teamProject = tpp.SelectedProjects[0].Name; TFSProject.Text = this.teamProject; WorkItem.IsEnabled = true; ExecuteButton.IsEnabled = true; ITestManagementService test_service = (ITestManagementService)this.tfs.GetService(typeof(ITestManagementService)); this.testManagementTeamProject = test_service.GetTeamProject(tpp.SelectedProjects[0].Name); } }
private void btnSelectSourceTfsProject_Click(object sender, EventArgs e) { _sourceTestManagementTeamProject = TfsOperations.SelectTfsProject(false); if (_sourceTestManagementTeamProject != null) { lblSourceTfsProject.Text = _sourceTestManagementTeamProject.ToString(); treeTestPlans.Nodes.Clear(); this.Refresh(); LoadTestPlansToForm(treeTestPlans); myStatus.Text = string.Empty; } }
public static int CreateNewStaticTestSuite(ITestManagementTeamProject teamProject, string testPlanName, string testSuiteName) { ITestPlan plan = GetTestPlan(teamProject, testPlanName); if (plan == null ) { CreateNewTestPlan(teamProject, testPlanName); } Console.WriteLine("Got Plan {0} with Id {1}", plan.Name, plan.Id); IStaticTestSuite newSuite = teamProject.TestSuites.CreateStatic(); newSuite.Title = testSuiteName; plan.RootSuite.Entries.Add(newSuite); plan.Save(); return newSuite.Id; }
/// <summary> /// Gets all test plans in specified TFS team project. /// </summary> /// <param name="testManagementTeamProject">The _testproject.</param> /// <returns>collection of all test plans</returns> public static ITestPlanCollection GetAllTestPlans(ITestManagementTeamProject testManagementTeamProject) { ITestPlanCollection testPlanCollection = null; int retryCount = 0; try { testPlanCollection = testManagementTeamProject.TestPlans.Query("SELECT * FROM TestPlan"); } catch (Exception ex) { log.Error("Getting all plans error.", ex); retryCount++; throw ex; } return testPlanCollection; }
/// <summary> /// Gets TestPlan by name. /// </summary> /// <param name="testManagementTeamProject">TFS team project</param> /// <param name="testPlanName">Name of the test plan.</param> /// <returns>the found test plan</returns> public static ITestPlan GetTestPlanByName(ITestManagementTeamProject testManagementTeamProject, string testPlanName) { ITestPlanCollection testPlans = GetAllTestPlans(testManagementTeamProject); ITestPlan testPlan = null; if (testPlans != null) { foreach (ITestPlan currentTestPlan in testPlans) { if (currentTestPlan.Name.Equals(testPlanName)) { testPlan = currentTestPlan; break; } } } return testPlan; }
/// <summary> /// Copies a test plan. /// </summary> /// <param name="destinationProject">The destination project.</param> /// <param name="sourceTestPlan">The source test plan.</param> public static string CopyTestPlan(ITestManagementTeamProject destinationProject, ITestPlan sourceTestPlan) { string results = "Copying Test Plan " + sourceTestPlan.Name + Environment.NewLine; CreateAndCollectInfoForDestinationAreaAndIterations(destinationProject, sourceTestPlan.Project.WitProject); ITestPlan destinationTestPlan = destinationProject.TestPlans.Create(); destinationTestPlan.Name = sourceTestPlan.Name; destinationTestPlan.StartDate = sourceTestPlan.StartDate; destinationTestPlan.EndDate = sourceTestPlan.EndDate; destinationTestPlan.Save(); results += CopyTestCases(sourceTestPlan.RootSuite, destinationTestPlan.RootSuite); results += CopyTestSuites(sourceTestPlan, destinationTestPlan); return results; }
/// <summary> /// Load project settings from TFS team project picker. /// </summary> /// <param name="projectPicker">The project picker.</param> public void LoadProjectSettingsFromUserDecision(TeamProjectPicker projectPicker, ref TfsTeamProjectCollection tfsTeamProjectCollection, ref ITestManagementTeamProject testManagementTeamProject, ref Preferences preferences, ITestManagementService testService, string selectedTestPlan, bool writeToRegistry = true) { preferences = new Preferences(); log.Info("Load project info depending on the user choice from project picker!"); try { using (projectPicker) { var userSelected = projectPicker.ShowDialog(); if (userSelected == DialogResult.Cancel) { return; } if (projectPicker.SelectedTeamProjectCollection != null) { preferences.TfsUri = projectPicker.SelectedTeamProjectCollection.Uri; log.InfoFormat("Picker: TFS URI: {0}", preferences.TfsUri); preferences.TestProjectName = projectPicker.SelectedProjects[0].Name; log.InfoFormat("Picker: Test Project Name: {0}", preferences.TestProjectName); tfsTeamProjectCollection = projectPicker.SelectedTeamProjectCollection; log.InfoFormat("Picker: TfsTeamProjectCollection: {0}", tfsTeamProjectCollection); testService = (ITestManagementService)tfsTeamProjectCollection.GetService(typeof(ITestManagementService)); testManagementTeamProject = testService.GetTeamProject(preferences.TestProjectName); } log.InfoFormat("Test Project Name: {0}", preferences.TestProjectName); log.InfoFormat("TFS URI: {0}", preferences.TfsUri); if (writeToRegistry) { RegistryManager.Instance.WriteCurrentTeamProjectName(preferences.TestProjectName); RegistryManager.Instance.WriteCurrentTeamProjectUri(preferences.TfsUri.ToString()); } } } catch (Exception ex) { ModernDialog.ShowMessage("Error selecting team project.", "Warning", MessageBoxButton.OK); log.Error("Project info not selected.", ex); } }
/// <summary> /// Gets the test steps from test actions. /// </summary> /// <param name="testActions">The test actions.</param> /// <param name="alreadyAddedSharedSteps">The already added shared steps.</param> /// <param name="sharedSteps">The shared steps.</param> /// <returns>list of all test steps</returns> public static List<TestStep> GetTestStepsFromTestActions(ITestManagementTeamProject testManagementTeamProject, ICollection<ITestAction> testActions) { List<TestStep> testSteps = new List<TestStep>(); foreach (var currentAction in testActions) { if (currentAction is ITestStep) { Guid testStepGuid = Guid.NewGuid(); testSteps.Add(new TestStep(false, string.Empty, testStepGuid, currentAction as ITestStep)); } else if (currentAction is ISharedStepReference) { ISharedStepReference currentSharedStepReference = currentAction as ISharedStepReference; ISharedStep currentSharedStep = testManagementTeamProject.SharedSteps.Find(currentSharedStepReference.SharedStepId); testSteps.AddRange(TestStepManager.GetAllTestStepsInSharedStep(currentSharedStep)); } } return testSteps; }
/// <summary> /// Gets the test plans for TFS project. /// </summary> /// <param name="project">The project.</param> /// <returns></returns> public static ITestPlanCollection GetTestPlansForTfsProject(ITestManagementTeamProject project) { ITestPlanCollection retVal = project.TestPlans.Query("Select * From TestPlan"); return retVal; }
/// <summary> /// Gets the default configuration collection. /// </summary> /// <param name="project">The project.</param> /// <returns></returns> private static IdAndName[] GetDefaultConfigurationCollection(ITestManagementTeamProject project) { ITestConfiguration defaultConfig = null; foreach (ITestConfiguration config in project.TestConfigurations.Query("Select * from TestConfiguration")) { defaultConfig = config; break; } IdAndName defaultConfigIdAndName = new IdAndName(defaultConfig.Id, defaultConfig.Name); return new IdAndName[] { defaultConfigIdAndName }; }
private static string CreateAndCollectInfoForDestinationAreaAndIterations(ITestManagementTeamProject destinationTestProject, Project sourceWitProject) { if (_destinationStructureService == null) { return "******** Couldn't connect to the Destination Structure Service, cannot create Areas or Iterations" + Environment.NewLine; } string rootAreaNodePath = string.Format("\\{0}\\Area", destinationTestProject.TeamProjectName); NodeInfo areaPathRootInfo = _destinationStructureService.GetNodeFromPath(rootAreaNodePath); _destinationAreaNodes.Clear(); RecurseAreas(sourceWitProject.AreaRootNodes, areaPathRootInfo, destinationTestProject.WitProject.AreaRootNodes, destinationTestProject.WitProject); string rootIterationNodePath = string.Format("\\{0}\\Iteration", destinationTestProject.TeamProjectName); NodeInfo iterationPathRootInfo = _destinationStructureService.GetNodeFromPath(rootIterationNodePath); _destinationIterationNodes.Clear(); RecurseIterations(sourceWitProject.IterationRootNodes, iterationPathRootInfo, destinationTestProject.WitProject.IterationRootNodes, destinationTestProject.WitProject); return string.Empty; }
private void btn_connect_Click(object sender, RoutedEventArgs e) { this._tfs = null; Sel_TPlan.Items.Clear(); treeView_suite.Items.Clear(); TFS_Textbox.Text = null; TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); tpp.ShowDialog(); if (tpp.SelectedTeamProjectCollection != null) { this._tfs = tpp.SelectedTeamProjectCollection; ITestManagementService test_service = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService)); _store = (WorkItemStore)_tfs.GetService(typeof(WorkItemStore)); TFS_Textbox.Text = this._tfs.Name; string proj_name = tpp.SelectedProjects[0].Name; _testproject = test_service.GetTeamProject(proj_name); if (_testproject != null) { TFS_Textbox.Text = TFS_Textbox.Text + "\\" + _testproject.ToString(); GetTestPlans(_testproject); } else MessageBox.Show("Please select a valid Team Project"); } }
void GetTestPlans(ITestManagementTeamProject _testproject) { Sel_TPlan.Visibility = Visibility.Visible; Lbl_TPlan.Visibility=Visibility.Visible; Lbl_TSuites.Visibility = Visibility.Visible; Gen_Btn.Visibility = Visibility.Visible; treeView_suite.Background = System.Windows.Media.Brushes.White; treeView_suite.BorderBrush = System.Windows.Media.Brushes.Black; foreach (ITestPlan tp in _testproject.TestPlans.Query("Select * from TestPlan")) { string t_plan = tp.Name +" <ID: " + tp.Id.ToString() + " >"; Sel_TPlan.Items.Add(t_plan); } }
/// <summary> /// Sets the test case suite. /// </summary> /// <param name="suiteId">The suite unique identifier.</param> /// <param name="testCase">The test case.</param> private static void SetTestCaseSuite(ITestManagementTeamProject testManagementTeamProject, ITestPlan testPlan, int suiteId, TestCase testCase) { var newSuite = TestSuiteManager.GetTestSuiteById(testManagementTeamProject, testPlan, suiteId); if (newSuite != null) { newSuite.AddTestCase(testCase.ITestCase); testCase.ITestSuiteBase = newSuite; } }
private void ApplyUserServerPreferences() { if (_userPreferences.TfsUri.Value == null || String.IsNullOrEmpty(_userPreferences.TestProject)) { return; } _logger.Info("Apply server preferences. TFS URI: {0}; TestProject: {1}", _userPreferences.TfsUri.Value, _userPreferences.TestProject); _tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_userPreferences.TfsUri); _tfs.Connect(ConnectOptions.IncludeServices); _testProject = _tfs.GetService<ITestManagementService>().GetTeamProject(_userPreferences.TestProject); _changeProjectToolStripButton.Text = _userPreferences.TestProject; }