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}"); }
/// <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 <TestSuite> testSuites = proxy.GetFirstLevelTestSuitesForTestProject(projectId); //GetTestSuitesForTestPlan(testPlanId); // testsuite must exist. Currently no way of creating them foreach (TestSuite ts in testSuites) { if (ts.name == testSuiteName) { testSuiteId = ts.id; break; } } return(testSuiteId); }
/// <summary> /// This method is responsible for actually importing the data /// </summary> /// <param name="stateInfo">State information handle</param> /// <remarks>This runs in background thread to avoid freezing the progress form</remarks> public void ImportData(object stateInfo) { //First open up the textfile that we will log information to (used for debugging purposes) string debugFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\Spira_TestLink_Import.log"; StreamWriter streamWriter = File.CreateText(debugFile); try { streamWriter.WriteLine("Starting import at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); //Create the mapping hashtables this.testCaseMapping = new Dictionary <int, int>(); this.testSuiteMapping = new Dictionary <int, int>(); this.testSuiteSectionMapping = new Dictionary <int, int>(); this.testStepMapping = new Dictionary <int, int>(); this.usersMapping = new Dictionary <int, int>(); this.testRunStepMapping = new Dictionary <int, int>(); this.testRunStepToTestStepMapping = new Dictionary <int, int>(); this.testSetMapping = new Dictionary <int, int>(); this.testSetTestCaseMapping = new Dictionary <int, int>(); //Connect to Spira streamWriter.WriteLine("Connecting to Spira..."); SpiraSoapService.SoapServiceClient spiraClient = new SpiraSoapService.SoapServiceClient(); //Set the end-point and allow cookies string spiraUrl = Properties.Settings.Default.SpiraUrl + ImportForm.IMPORT_WEB_SERVICES_URL; spiraClient.Endpoint.Address = new EndpointAddress(spiraUrl); BasicHttpBinding httpBinding = (BasicHttpBinding)spiraClient.Endpoint.Binding; ConfigureBinding(httpBinding, spiraClient.Endpoint.Address.Uri); bool success = spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestLinkImporter"); if (!success) { string message = "Failed to authenticate with Spira using login: '******' so terminating import!"; streamWriter.WriteLine(message); streamWriter.Close(); //Display the exception message this.progressForm.ProgressForm_OnError(message); return; } //Connect to TestLink string apiKey = Properties.Settings.Default.TestLinkApiKey; string testLinkUrl = Properties.Settings.Default.TestLinkUrl + Utils.TESTLINK_URL_SUFFIX_XML_RPC; TestLink testLink = new TestLink(apiKey, testLinkUrl); //1) Create a new project ImportProject(streamWriter, spiraClient, testLink); //**** Show progress **** streamWriter.WriteLine("Project Created"); this.progressForm.ProgressForm_OnProgressUpdate(1); //2) Import test suites //Get the test suites from the TestLink API List <TestSuite> testSuites = testLink.GetFirstLevelTestSuitesForTestProject(this.testLinkProjectId); ImportTestSuites(streamWriter, spiraClient, testLink, testSuites); //**** Show progress **** streamWriter.WriteLine("Imported Test Suites"); this.progressForm.ProgressForm_OnProgressUpdate(2); //**** Show progress **** streamWriter.WriteLine("Imported Test Cases and Steps"); this.progressForm.ProgressForm_OnProgressUpdate(3); //3) Import test cases and test steps ImportTestCasesAndSteps(streamWriter, spiraClient, testLink); //**** Show progress **** streamWriter.WriteLine("Completed Import"); this.progressForm.ProgressForm_OnProgressUpdate(4); //**** Mark the form as finished **** streamWriter.WriteLine("Import completed at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); this.progressForm.ProgressForm_OnFinish(); //Close the debugging file streamWriter.Close(); } catch (Exception exception) { //Log the error streamWriter.WriteLine("*ERROR* Occurred during Import: '" + exception.Message + "' at " + exception.Source + " (" + exception.StackTrace + ")"); streamWriter.Close(); //Display the exception message this.progressForm.ProgressForm_OnError(exception); } }