예제 #1
0
        /// <summary>
        /// The log
        /// </summary>
        //private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCaseExecutionArrangmentViewModel"/> class.
        /// </summary>
        public TestPlansEditViewModel()
        {
            this.ObservableTestPlans = new ObservableCollection <TestPlan>();
            ITestPlanCollection testPlanCores = TestPlanManager.GetAllTestPlans(ExecutionContext.TestManagementTeamProject);

            testPlanCores.ToList().ForEach(t => this.ObservableTestPlans.Add(new TestPlan(t)));
        }
예제 #2
0
        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;
        }
예제 #3
0
        internal override void InternalExecute()
        {
            ITestPlanCollection sourcePlans = sourceTestStore.GetTestPlans();

            Trace.WriteLine(string.Format("Plan to copy {0} Plans?", sourcePlans.Count), "TestPlansAndSuites");
            foreach (ITestPlan sourcePlan in sourcePlans)
            {
                string newPlanName = string.Format("{0}-{1}", sourceWitStore.GetProject().Name, sourcePlan.Name);
                Trace.WriteLine(string.Format("Process Plan {0} - ", newPlanName), "TestPlansAndSuites");
                ITestPlan targetPlan = FindTestPlan(targetTestStore, newPlanName);
                if (targetPlan == null)
                {
                    Trace.WriteLine(string.Format("    Plan missing...creating"), "TestPlansAndSuites");
                    targetPlan = CreateNewTestPlanFromSource(sourcePlan, newPlanName);
                    targetPlan.Save();
                }
                else
                {
                    Trace.WriteLine(string.Format("    Plan found"), "TestPlansAndSuites");
                }
                if (HasChildSuits(sourcePlan.RootSuite))
                {
                    Trace.WriteLine(string.Format("    Source Plan has {0} Suites", sourcePlan.RootSuite.Entries.Count), "TestPlansAndSuites");
                    foreach (ITestSuiteBase sourcerSuiteChild in sourcePlan.RootSuite.SubSuites)
                    {
                        ProcessStaticSuite(sourcerSuiteChild, targetPlan.RootSuite, targetPlan);
                    }
                    // Add Test Cases
                    ProcessChildTestCases(sourcePlan.RootSuite, targetPlan.RootSuite, targetPlan);
                }
            }
        }
        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;
        }
예제 #5
0
        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);
            }
        }
        private string GetLatestTestResult(int testId, ITestPlanCollection plans)
        {
            ITestPoint mostRecentPoint = null;

            foreach (ITestPlan plan in plans)
            {
                var points = plan.QueryTestPoints(string.Format("SELECT * FROM TestPoint WHERE TestCaseId = {0}", testId));
                foreach (ITestPoint point in points)
                {
                    if (mostRecentPoint == null || mostRecentPoint.LastUpdated < point.LastUpdated)
                    {
                        mostRecentPoint = point;
                    }
                }
            }

            if (mostRecentPoint == null)
            {
                return("N/A");
            }

            var mostRecent = "Not run";

            if (mostRecentPoint.MostRecentResult != null)
            {
                mostRecent = mostRecentPoint.MostRecentResult.Outcome.ToString();
            }
            return(mostRecent);
        }
        internal override void InternalExecute()
        {
            ITestPlanCollection sourcePlans = sourceTestStore.GetTestPlans();

            Trace.WriteLine(string.Format("Plan to copy {0} Plans?", sourcePlans.Count), "TestPlansAndSuites");
            foreach (ITestPlan sourcePlan in sourcePlans)
            {
                if (CanSkipElementBecauseOfTags(sourcePlan.Id))
                {
                    continue;
                }

                var newPlanName = config.PrefixProjectToNodes
                    ? $"{sourceWitStore.GetProject().Name}-{sourcePlan.Name}"
                    : $"{sourcePlan.Name}";

                Trace.WriteLine($"Process Plan {newPlanName}", Name);
                var targetPlan = FindTestPlan(targetTestStore, newPlanName);
                if (targetPlan == null)
                {
                    Trace.WriteLine("    Plan missing... creating", Name);
                    targetPlan = CreateNewTestPlanFromSource(sourcePlan, newPlanName);

                    RemoveInvalidLinks(targetPlan);

                    targetPlan.Save();

                    ApplyFieldMappings(sourcePlan.Id, targetPlan.Id);
                    AssignReflectedWorkItemId(sourcePlan.Id, targetPlan.Id);
                    FixAssignedToValue(sourcePlan.Id, targetPlan.Id);

                    ApplyDefaultConfigurations(sourcePlan.RootSuite, targetPlan.RootSuite);

                    ApplyFieldMappings(sourcePlan.RootSuite.Id, targetPlan.RootSuite.Id);
                    AssignReflectedWorkItemId(sourcePlan.RootSuite.Id, targetPlan.RootSuite.Id);
                    FixAssignedToValue(sourcePlan.RootSuite.Id, targetPlan.RootSuite.Id);
                    // Add Test Cases & apply configurations
                    AddChildTestCases(sourcePlan.RootSuite, targetPlan.RootSuite, targetPlan);
                }
                else
                {
                    Trace.WriteLine("    Plan already found, not creating", Name);
                }
                if (HasChildSuites(sourcePlan.RootSuite))
                {
                    Trace.WriteLine($"    Source Plan has {sourcePlan.RootSuite.Entries.Count} Suites", Name);
                    foreach (var sourceSuiteChild in sourcePlan.RootSuite.SubSuites)
                    {
                        ProcessTestSuite(sourceSuiteChild, targetPlan.RootSuite, targetPlan);
                    }
                }

                targetPlan.Save();
                // Load the plan again, because somehow it doesn't let me set configurations on the already loaded plan
                ITestPlan targetPlan2 = FindTestPlan(targetTestStore, targetPlan.Name);
                ApplyConfigurationsAndAssignTesters(sourcePlan.RootSuite, targetPlan2.RootSuite);
            }
        }
        /// <summary>
        /// Initializes the test plans.
        /// </summary>
        /// <param name="testManagementTeamProject">The _testproject.</param>
        public void InitializeTestPlans(ITestManagementTeamProject testManagementTeamProject, ICollection <string> testPlans)
        {
            testPlans.Clear();
            ITestPlanCollection testPlansCollection = TestPlanManager.GetAllTestPlans(testManagementTeamProject);

            foreach (ITestPlan tp in testPlansCollection)
            {
                testPlans.Add(tp.Name);
            }
        }
예제 #9
0
 /// <summary>
 /// Gets the list of test plans under the selected project.
 /// </summary>
 public Task <List <ITestPlan> > GetTestPlans(Project currentProjectRef)
 {
     return(Task.Factory.StartNew(() =>
     {
         List <ITestPlan> planList = new List <ITestPlan>();
         this.Session.workingProject = Session.TestService.GetTeamProject(currentProjectRef.Name);
         ITestPlanCollection plans = Session.workingProject.TestPlans.Query("SELECT * FROM TestPlan Order By PlanName");
         return plans.ToList();
     }));
 }
        public static IOrderedEnumerable <TestPlan> getTestPlans(TeamProject teamProject)
        {
            ITestPlanCollection testPlanCollection = teamProject.TFSTestManagementTeamProject.TestPlans.Query("Select * From TestPlan");

            TestPlan[] testPlans = new TestPlan[testPlanCollection.Count];

            for (int i = 0; i < testPlanCollection.Count; i++)
            {
                testPlans[i] = new TestPlan(testPlanCollection[i]);
            }

            return(testPlans.OrderBy(tp => tp.TFSTestPlan.Name));
        }
예제 #11
0
 private void Get_TestPlans(ITestManagementTeamProject teamProject)
 {
     //Getting all the test plans in the collection "plans" using the query.
     this.plans = teamProject.TestPlans.Query("Select * From TestPlan");
     comBoxTestPlan.Items.Clear();
     flag2 = 0;
     comBoxTestSuite.Items.Clear();
     flag3 = 0;
     foreach (ITestPlan plan in plans)
     {
         //Populating the plan selection dropdown list with the name of Test Plans in the selected team project.
         comBoxTestPlan.Items.Add(plan.Name);
     }
 }
        public static SortedDictionary <string, string> GetTestPlans(string collectionName, string projectName)
        {
            tfs  = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(XML.GetCollectionURL(collectionName)));
            tms  = tfs.GetService <ITestManagementService>();
            proj = tms.GetTeamProject(projectName);
            iTPC = proj.TestPlans.Query("Select * From TestPlan");
            SortedDictionary <string, string> iTP = new SortedDictionary <string, string>();

            foreach (ITestPlan itp in iTPC)
            {
                iTP.Add(itp.Id.ToString(), itp.Name);
            }
            return(iTP);
        }
        /// <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);
        }
        internal override void InternalExecute()
        {
            ITestPlanCollection sourcePlans = sourceTestStore.GetTestPlans();

            Trace.WriteLine(string.Format("Plan to copy {0} Plans?", sourcePlans.Count), "TestPlansAndSuites");
            foreach (ITestPlan sourcePlan in sourcePlans)
            {
                if (CanSkipElementBecauseOfTags(sourcePlan.Id))
                {
                    continue;
                }

                var newPlanName = config.PrefixProjectToNodes
                    ? $"{sourceWitStore.GetProject().Name}-{sourcePlan.Name}"
                    : $"{sourcePlan.Name}";

                Trace.WriteLine($"Process Plan {newPlanName}", Name);
                var targetPlan = FindTestPlan(targetTestStore, newPlanName);
                if (targetPlan == null)
                {
                    Trace.WriteLine("    Plan missing... creating", Name);
                    targetPlan = CreateNewTestPlanFromSource(sourcePlan, newPlanName);
                    targetPlan.Save();
                    AssignReflectedWorkItemId(sourcePlan.Id, targetPlan.Id);
                    FixAssignedToValue(sourcePlan.Id, targetPlan.Id);
                    AssignReflectedWorkItemId(sourcePlan.RootSuite.Id, targetPlan.RootSuite.Id);
                    FixAssignedToValue(sourcePlan.RootSuite.Id, targetPlan.RootSuite.Id);
                }
                else
                {
                    Trace.WriteLine("    Plan found", Name);
                }
                if (HasChildSuits(sourcePlan.RootSuite))
                {
                    Trace.WriteLine($"    Source Plan has {sourcePlan.RootSuite.Entries.Count} Suites", Name);
                    foreach (var sourcerSuiteChild in sourcePlan.RootSuite.SubSuites)
                    {
                        ProcessStaticSuite(sourcerSuiteChild, targetPlan.RootSuite, targetPlan);
                    }
                    // Add Test Cases
                    ProcessChildTestCases(sourcePlan.RootSuite, targetPlan.RootSuite, targetPlan);
                }
            }
        }
        /// <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>
        /// Loads the test plans for the selected Source TFS project to the treeView control.
        /// </summary>
        /// <param name="treeView">The tree view.</param>
        private void LoadTestPlansToForm(TreeView treeView)
        {
            ITestPlanCollection sourceTestPlans = TfsOperations.GetTestPlansForTfsProject(_sourceTestManagementTeamProject);

            int planIndex = 1;

            foreach (ITestPlan plan in sourceTestPlans)
            {
                myStatus.Text = string.Format("Loading Test Plan '{0}' ({1}/{2})", plan.Name, planIndex, sourceTestPlans.Count);
                this.Refresh();

                TreeNode planNode = new TreeNode(plan.Name, 1, 1);
                planNode.Tag = plan;

                treeView.Nodes.Add(planNode);

                planIndex++;
            }

            myStatus.Text = string.Empty;
        }
예제 #17
0
        private static void GetTestPlans(ITestManagementTeamProject testproject, int TeamId)
        {
            ITestPlanCollection plans = testproject.TestPlans.Query("Select * From TestPlan");

            List <TestPlan> testPlans = new List <TestPlan>();

            foreach (ITestPlan plan in plans)
            {
                TestPlan testPlan = new TestPlan();
                testPlan.TeamId        = TeamId;
                testPlan.TestPlanName  = plan.Name;
                testPlan.PlanId        = plan.Id;
                testPlan.TestCaseCount = 0;

                if (plan.RootSuite != null && plan.RootSuite.Entries.Count > 0)
                {
                    var Suites = GetPlanSuites(plan.RootSuite.Entries);
                    foreach (var suite in Suites)
                    {
                        suite.TestPlan = testPlan;
                        testPlan.TestSuites.Add(suite);
                    }
                }
                testPlans.Add(testPlan);
            }

            foreach (var item in testPlans)
            {
                item.TestCaseCount = item.TestSuites.Where(s => s.ParentSuite == -1).Sum(col => col.TotalTests);
            }

            DeleteTestSuitesFromDB(TeamId);

            foreach (var testPlan in testPlans)
            {
                db.TestPlans.Add(testPlan);
                db.Entry(testPlan).State = System.Data.Entity.EntityState.Added;
            }
            db.SaveChanges();
        }
예제 #18
0
        /// <summary>
        /// Проходит по всем тестовым ситуациям тестового плана и заполняет Excel таблицу,
        /// указывая подзаголовком категорию теста - наименования тестовой ситуации.
        /// </summary>
        private void ByTestSuites()
        {
            try
            {
                this.plans = teamProject.TestPlans.Query("Select * From TestPlan");
                foreach (ITestPlan plan in plans)
                {
                    if (plan.Name == testPlanName)
                    {
                        this.testSuites = plan.RootSuite.Entries;
                    }
                }
                foreach (ITestSuiteEntry suite_entry in testSuites)
                {
                    this.suite = suite_entry;
                    IStaticTestSuite newSuite = suite_entry.TestSuite as IStaticTestSuite;
                    if (newSuite != null)
                    {
                        xlWorkSheet.get_Range("a" + row, "d" + row).Merge(true);
                        xlWorkSheet.Cells[row, 1]                     = newSuite.Title;
                        xlWorkSheet.Cells[row, 1].Font.Bold           = true;
                        xlWorkSheet.Cells[row, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;

                        row = row + 1;
                        ITestCaseCollection cases = newSuite.AllTestCases;
                        ByTestCases(cases);
                    }
                    else
                    {
                        ITestCase test = suite_entry.TestCase as ITestCase;
                        if (test != null)
                        {
                            ByTest(test);
                        }
                    }
                }
            }
            catch { }
        }
예제 #19
0
        /// <summary>
        /// Gets a list of projects for the user.
        /// </summary>
        public Task <List <Project> > GetProjects()
        {
            return(Task.Factory.StartNew(() =>
            {
                //Retrieve the user's project list
                WorkItemStore workItems = new WorkItemStore(Session.ProjectCollection);
                ProjectCollection projects = workItems.Projects;

                var projectList = new List <Project>();
                foreach (Project p in projects)
                {
                    // try to list test plans for each project, if none are returned then user does not have access
                    var proj = Session.TestService.GetTeamProject(p.Name);
                    ITestPlanCollection plans = proj.TestPlans.Query("SELECT * FROM TestPlan");
                    if (plans.Count != 0)
                    {
                        projectList.Add(p);
                    }
                }
                return projectList;
            }));
        }
예제 #20
0
        void GetTestPlans(ITestManagementTeamProject testproject)
        {
            ITestPlanCollection plans = testproject.TestPlans.Query("Select * From TestPlan");

            TreeViewItem root = null;

            root        = new TreeViewItem();
            root.Header = ImageHelpers.CreateHeader(testproject.WitProject.Name, ItemTypes.TeamProject);
            TreeMain.Items.Add(root);

            foreach (ITestPlan plan in plans)
            {
                TreeViewItem plan_tree = new TreeViewItem();
                plan_tree.Header = ImageHelpers.CreateHeader(plan.Name, ItemTypes.TestPlan);

                if (plan.RootSuite != null && plan.RootSuite.Entries.Count > 0)
                {
                    GetPlanSuites(plan.RootSuite.Entries, plan_tree);
                }

                root.Items.Add(plan_tree);
            }
        }
예제 #21
0
        /// <summary>
        /// This method is used to initiate execution in test manager, create test run and results and set required parameters
        /// </summary>
        /// <returns></returns>
        public bool InitExecution()
        {
            //Create a connection to tfs project
            ITestManagementTeamProject tfsProject = null;

            tfsProject = GetProject(ProjectUrl, ProjectName);

            if (tfsProject == null)
            {
                throw new Exception("Unabled to connect to test project: " + ProjectName);
            }
            //Retrieve test plan details
            ITestPlanCollection testPlans = tfsProject.TestPlans.Query("select * from TestPlan where PlanName ='" +
                                                                       TestPlanName + "'");

            if (testPlans.Count == 0)
            {
                throw new Exception("Unabled to locate test plan: " + TestPlanName + " in Test Manager.");
            }

            ITestPlan tfsTestPlan = testPlans.First();

            //Retrieve test suite details
            ITestSuiteCollection testSuites = null;

            //Optionally, test suite id of test manager can be passed as an command line arguments
            //This helps when same test case has been added to multiple test suites
            if (TestSuiteId.ToLower().Equals(string.Empty) ||
                TestSuiteId.ToLower().Equals(string.Empty) ||
                TestSuiteId.ToLower().Equals("testsuiteid", StringComparison.OrdinalIgnoreCase))
            {
                testSuites = tfsProject.TestSuites.Query("Select * from TestSuite where Title='" +
                                                         TestSuiteName + "' and PlanID='" + tfsTestPlan.Id + "'");
            }
            else
            {
                testSuites = tfsProject.TestSuites.Query("Select * from TestSuite where Id='" +
                                                         TestSuiteId + "' and PlanID='" + tfsTestPlan.Id + "'");
            }


            IStaticTestSuite tfsTestSuite = testSuites.Cast <IStaticTestSuite>().FirstOrDefault(testSuite => testSuite.Title.ToLower().Equals(TestSuiteName.ToLower()) || testSuite.Id.ToString().Equals(TestSuiteId));

            if (tfsTestSuite == null)
            {
                throw new Exception("Unabled to locate test suite: " + TestSuiteName + " in Test Manager Test Plan: " + TestPlanName);
            }

            //Get handle to a specific test case in the test suite
            ITestCase tfsTestCase = tfsTestSuite.AllTestCases.FirstOrDefault(testcase => testcase.Id.Equals(TestCaseId));

            if (tfsTestCase == null)
            {
                throw new Exception("Unabled to locate test case id: " + TestCaseId + " in Test Manager");
            }

            //Create a test run
            ITestPoint tfsTestPoint = CreateTestPoints(tfsTestPlan, tfsTestSuite, tfsTestCase);
            ITestRun   tfsTestRun   = CreateTestRun(tfsProject, tfsTestPlan, tfsTestPoint);

            tfsTestRun.Refresh();

            //Suprisingly, most recently created test results should be available in last, but test manager returns it at first position
            //Find test results that were create by the test run
            ITestCaseResultCollection tfsTestCaseResults = tfsProject.TestResults.ByTestId(tfsTestCase.Id);
            ITestCaseResult           tfsTestResult      = tfsTestCaseResults.Last(); //Default assignment

            foreach (ITestCaseResult testResult in tfsTestCaseResults)
            {
                if (testResult.DateCreated.CompareTo(tfsTestRun.DateCreated) == 1)
                {
                    tfsTestResult = testResult;
                    break;
                }
            }

            //Set test run and result id to property variable for usage while uploading results
            Property.RcTestRunId    = tfsTestRun.Id;
            Property.RcTestResultId = tfsTestResult.TestResultId;

            //Set status of test case execution

            //Set other details on test execution
            tfsTestResult.ComputerName = Property.RcMachineId;
            tfsTestResult.DateStarted  = DateTime.Now;
            tfsTestResult.State        = TestResultState.InProgress;
            tfsTestResult.Save();
            return(true);
        }
예제 #22
0
 public static ITestCaseCollection GetTestCases(ITestPlanCollection testPlans)
 {
     //AllTestCases - Will show all the Test Cases under that Suite even in sub suites.
     return null;
 }
예제 #23
0
 /// <summary>
 ///Initiaze and get the test objects from the test managment.
 /// </summary>
 private static void InitializeTestData()
 {
     testCases  = testManagement.TestCases.Query("SELECT * FROM WorkItems");
     testSuites = testManagement.TestSuites.Query("SELECT * FROM TestSuite");
     testPlans  = testManagement.TestPlans.Query("SELECT * FROM TestPlan");
 }
예제 #24
0
        public static List<ITestCaseResult> GetTestResults(ITestPlanCollection testPlans)
        {
            List<ITestCaseResult> testResults = new List<ITestCaseResult>();
            // Loop through the test plan collection to read the associated test suite.
            foreach (ITestPlan testPlan in testPlans)
            {
                // Loop through the test suite to read the associated test case.
                foreach (ITestSuiteBase testSuite in testPlan.RootSuite.SubSuites)
                {
                    // Query Test points that holds the Test case and test result information
                    foreach (ITestPoint point in testPlan.QueryTestPoints(string.Format("SELECT * FROM TestPoint WHERE SuiteId = {0}", testSuite.Id)))
                    {
                        ITestCaseResult testResult = point.MostRecentResult;

                        if (point.MostRecentResult == null)
                        {
                            // test case is not executed at least once.
                        }
                        else
                        {
                            testResults.Add(testResult);
                        }
                    }
                }
            }
            return testResults;
        }
예제 #25
0
        /// <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);
        }
예제 #26
0
        internal static int Add_TestPlans(
            Excel.XlLocation insertAt,
            Options_AZDO_TFS options,
            ITestManagementTeamProject testManagementTeamProject)
        {
            Int64 startTicks = Log.APPLICATION("Enter", Common.LOG_CATEGORY);

            int itemCount = 0;

            //string query = String.Format(
            //    "SELECT [System.Id]"
            //    + " FROM TestPlan"
            //    + " WHERE [Team Project] = '{0}'", testManagementTeamProject.TeamProjectName);

            string query = String.Format(
                "SELECT *"
                + " FROM TestPlan");

            ITestPlanCollection testPlans = testManagementTeamProject.TestPlans.Query(query);
            int totalItems = testPlans.Count;

            XlHlp.DisplayInWatchWindow($"Processing ({ totalItems } testPlans");

            foreach (var testPlan in testPlans)
            {
                insertAt.ClearOffsets();

                XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testManagementTeamProject.TeamProjectName}");

                try
                {
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.Id}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.Name}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.Description}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.State}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.AreaPath}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.Iteration}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.StartDate}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.EndDate}");

                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.OwnerName}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.LastUpdated}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.LastUpdatedByName}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.Revision}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.Links.Count}");
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{testPlan.RootSuite.Id}");
                }
                catch (Exception ex)
                {
                    XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), $"{ex}");
                }

                insertAt.IncrementRows();
                itemCount++;

                AZDOHelper.ProcessItemDelay(options);
                AZDOHelper.DisplayLoopUpdates(startTicks, options, totalItems, itemCount);
            }

            Log.APPLICATION("Exit", Common.LOG_CATEGORY, startTicks);

            return(itemCount);
        }
 /// <summary>
 /// Main work method.
 /// </summary>
 /// <param name="newTestPlans">All test plans inside the team project.</param>
 /// <param name="plansJSONPath">The path to write the audit .json to</param>
 /// <param name="logPath">The path to write errors etc.</param>
 /// <param name="csvPath">The path to write the audit .csv to</param>
 private static void GetAllTestPlanInfo(ITestPlanCollection newTestPlans, string plansJSONPath, string logPath, string csvPath)
 {
     List<MigrationTestPlan> testPlans = new List<MigrationTestPlan>();
     foreach (ITestPlan testPlan in newTestPlans)
     {
         // Check to see if we want to work on this plan
         bool collectLinks = YesNoInput("\nCollect links and perform alignment for Test Plan \"" + testPlan.Name + " (" + testPlan.Id + ")\"?\n\t" + "Enter y/n:");
         if (collectLinks)
         {                    
             List<MigrationWorkItem> migratedWorkItems = new List<MigrationWorkItem>();
             List<ITestCase> allTestCases = GetTestCases(testPlan);
             int i = 1;
             int numTestCases = allTestCases.Count;
             if (numTestCases > 0)
             {
                 Trace.Write("Processing all links in Plan \"" + testPlan.Name + " (" + testPlan.Id + ")\"...\n\t");
             }
             using (var progress = new ProgressBar())
             {
                 foreach (var testCase in allTestCases)
                 {
                     ProcessLinks(migratedWorkItems, testCase);
                     progress.Report((double)i / numTestCases);
                     i++;
                 }                        
             }
             testPlans.Add(new MigrationTestPlan()
             {
                 TestPlanName = testPlan.Name,
                 ID = testPlan.Id,
                 TestCases = migratedWorkItems
             });
         }                
     }
     PerformAlignment(logPath, testPlans);
     WritePlansAndAllLinks(plansJSONPath, csvPath, testPlans);
 }
        private string GetLatestTestResult(int testId, ITestPlanCollection plans)
        {
            ITestPoint mostRecentPoint = null;
            foreach (ITestPlan plan in plans)
            {
                var points = plan.QueryTestPoints(string.Format("SELECT * FROM TestPoint WHERE TestCaseId = {0}", testId));
                foreach (ITestPoint point in points)
                {
                    if (mostRecentPoint == null || mostRecentPoint.LastUpdated < point.LastUpdated)
                    {
                        mostRecentPoint = point;
                    }
                }
            }

            if (mostRecentPoint == null)
            {
                return "N/A";
            }

            var mostRecent = "Not run";
            if (mostRecentPoint.MostRecentResult != null)
            {
                mostRecent = mostRecentPoint.MostRecentResult.Outcome.ToString();
            }
            return mostRecent;
        }