Exemplo n.º 1
0
        /// <summary>
        /// retrieve the testsuite id
        /// </summary>
        /// <returns>0 or a valid test suite Id</returns>
        private int GetTestSuiteId(int projectId, string testSuiteName)
        {
            int testSuiteId = 0;
            List <Meyn.TestLink.TestSuite> testSuites = proxy.GetFirstLevelTestSuitesForTestProject(projectId); //GetTestSuitesForTestPlan(testPlanId);

            // testsuite must exist. Currently no way of creating them
            foreach (Meyn.TestLink.TestSuite ts in testSuites)
            {
                if (ts.name == testSuiteName)
                {
                    testSuiteId = ts.id;
                    break;
                }
            }
            return(testSuiteId);
        }
        /// <summary>
        /// retrieve the testsuite id
        /// </summary>
        /// <returns>0 or a valid test suite Id</returns>
        private int GetTestSuiteId(int projectId, string testSuiteName, bool createIfNotExisting)
        {
            int           testSuiteId       = 0;
            int           parentTestSuiteId = 0;
            GeneralResult result;

            string[] suites = testSuiteName.Split(new char[] { '.' });
            List <Meyn.TestLink.TestSuite> testSuites = proxy.GetFirstLevelTestSuitesForTestProject(projectId); //GetTestSuitesForTestPlan(testPlanId);

            for (int i = 0; i < suites.Length; i++)
            {
                testSuiteId = 0;
                foreach (Meyn.TestLink.TestSuite ts in testSuites)
                {
                    if (ts.name == suites[i])
                    {
                        parentTestSuiteId = testSuiteId = ts.id;
                        break;
                    }
                }
                if (testSuiteId == 0)
                {
                    if (createIfNotExisting)
                    {
                        result = proxy.CreateTestSuite(projectId, suites[i], "", parentTestSuiteId);
                        if (result.status == false)
                        {
                            log.ErrorFormat("Error trying to create new testsuite {0} ({1}): {2}", suites[i], testSuiteName, result.message);
                            return(0);
                        }
                        log.InfoFormat("Created new testsuite {0} ({1})", suites[i], testSuiteName);
                        parentTestSuiteId = testSuiteId = result.id;
                    }
                    else
                    {
                        return(0);
                    }
                }
                testSuites = proxy.GetTestSuitesForTestSuite(testSuiteId);
            }
            return(testSuiteId);
        }