Ejemplo n.º 1
0
        public void GetObjects()
        {
            Console.WriteLine(testlink.about());

            var projects = testlink.GetProjects();

            projects.ForEach(a => Console.WriteLine($"Project: {a.id}, {a.name}"));

            var project   = projects.First(a => a.name == "CMGE");
            var testPlans = testlink.GetProjectTestPlans(project.id);

            testPlans.ForEach(a => Console.WriteLine($"Test Plans: {a.id}, {a.name}"));

            var testSuites = testlink.GetFirstLevelTestSuitesForTestProject(project.id);

            testSuites.ForEach(a => Console.WriteLine($"Test Suites: {a.id}, {a.name}"));

            var testSuite = testSuites.First();
            var testCases = testlink.GetTestCasesForTestSuite(testSuite.id, false);

            testCases.ForEach(a => Console.WriteLine($"Test Cases: {a.id}, {a.name}"));

            var testCase = testlink.GetTestCase(4510, 1);

            Console.WriteLine($"Test Case: {testCase.id}, {testCase.name}");
        }
Ejemplo n.º 2
0
        public void Run()
        {
            SetAdapter();
            SetPlan();
            var      result    = _wrappedTestCase.RunTest();
            TestCase currentTC = _apiAdapter.GetTestCase(_apiAdapter.GetTestCaseIDByName(_testCaseName, _testSuiteName)[0].id);

            Console.WriteLine(String.Format("Result: {0}. Message: {1}", result.Status, result.Message));
            try
            {
                _apiAdapter.ReportTCResult(currentTC.testcase_id, _testPlan.id, result.Status,
                                           platformId: _apiAdapter.GetTestPlanPlatforms(_testPlan.id).First(e => e.name == _testPlatformName).id,
                                           overwrite: false, notes: result.Message);

                Console.WriteLine("Test results successfully send to TestlinkServer");
            }
            catch (TestCaseException exeption)
            {
                Console.WriteLine("Test result can not be saved because TestCase (" + _testCaseName + "), TestSuit ("
                                  + _testSuiteName + ") does not exist for current TestPlan (" + _testPlanName
                                  + ") or TestPlatform (" + _testPlatformName + ")." + exeption.Message);
            }
        }
Ejemplo n.º 3
0
 public String GetTestCaseTitle(int testCaseId)
 {
     return(testLink.GetTestCase(testCaseId).name);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Imports test cases and associated steps
        /// </summary>
        private void ImportTestCasesAndSteps(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, TestLink testLinkApi)
        {
            //Loop through all the mapped, imported test suites
            foreach (KeyValuePair <int, int> kvp in this.testSuiteMapping)
            {
                //Get the test cases from the TestLink API
                int testSuiteId  = kvp.Key;
                int testFolderId = kvp.Value;
                streamWriter.WriteLine(String.Format("Getting test cases in test suite: {0}", testSuiteId));
                List <TestCaseFromTestSuite> testCasesInSuite = testLinkApi.GetTestCasesForTestSuite(testSuiteId, true);
                if (testCasesInSuite != null)
                {
                    foreach (TestCaseFromTestSuite testCaseInSuite in testCasesInSuite)
                    {
                        //Extract the user data
                        int    tlTestCaseId         = testCaseInSuite.id;
                        string tlTestCaseExternalId = testCaseInSuite.external_id;
                        streamWriter.WriteLine(String.Format("Finding test case: {0} - {1}", tlTestCaseId, tlTestCaseExternalId));

                        //Get the actual test case object (with steps)
                        try
                        {
                            TestCase testCase = testLinkApi.GetTestCase(tlTestCaseId);
                            if (testCase != null)
                            {
                                streamWriter.WriteLine(String.Format("Importing test case: {0}", tlTestCaseId));
                                string description = "";
                                if (!String.IsNullOrEmpty(testCase.summary))
                                {
                                    description += "<p>" + testCase.summary + "</p>";
                                }
                                if (!String.IsNullOrEmpty(testCase.preconditions))
                                {
                                    description += "<p>" + testCase.preconditions + "</p>";
                                }

                                //Reauthenticate at this point, in case disconnected
                                spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestLinkImporter");
                                spiraClient.Connection_ConnectToProject(this.newProjectId);

                                //Create the new SpiraTest test case
                                RemoteTestCase remoteTestCase = new RemoteTestCase();
                                remoteTestCase.Name             = testCase.name;
                                remoteTestCase.Description      = description;
                                remoteTestCase.TestCaseTypeId   = /* Functional */ 3;
                                remoteTestCase.TestCaseStatusId = (testCase.active) ? /* Ready For Test */ 5 : /* Draft*/ 1;
                                remoteTestCase.CreationDate     = testCase.creation_ts;
                                if (testCase.importance >= 1 && testCase.importance <= 4)
                                {
                                    remoteTestCase.TestCasePriorityId = testCase.importance;
                                }

                                //We don't import the author currently
                                //remoteTestCase.AuthorId = this.usersMapping[createdById.Value];

                                //Map to the folder
                                remoteTestCase.TestCaseFolderId = testFolderId;

                                int newTestCaseId = spiraClient.TestCase_Create(remoteTestCase).TestCaseId.Value;
                                streamWriter.WriteLine("Added test case: " + tlTestCaseId);

                                //See if we have any test steps for this test case
                                if (testCase.steps != null && testCase.steps.Count > 0)
                                {
                                    streamWriter.WriteLine("Adding " + testCase.steps.Count + " test steps to test case: " + tlTestCaseId);
                                    foreach (TestStep testStep in testCase.steps)
                                    {
                                        RemoteTestStep remoteTestStep = new RemoteTestStep();
                                        remoteTestStep.Description    = testStep.actions;
                                        remoteTestStep.ExpectedResult = testStep.expected_results;
                                        spiraClient.TestCase_AddStep(remoteTestStep, newTestCaseId);
                                    }
                                    streamWriter.WriteLine("Added test steps to test case: " + tlTestCaseId);
                                }

                                //Add to the mapping hashtables
                                if (!this.testCaseMapping.ContainsKey(tlTestCaseId))
                                {
                                    this.testCaseMapping.Add(tlTestCaseId, newTestCaseId);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            streamWriter.WriteLine(String.Format("Error importing test case {0}: {1} ({2})", tlTestCaseId, ex.Message, ex.StackTrace));
                        }
                    }
                }
            }
        }