/// <summary> /// The SetTestSetByUID. /// </summary> /// <param name="uID">The UID<see cref="int"/>.</param> /// <returns>The <see cref="TestSetInstance"/>.</returns> public TestSetInstance SetTestSetByUID(int uID) { // create a new filter filtering out by UID TestSetFactory factory = this.connection.TestSetFactory as TestSetFactory; TDFilter filter = factory.Filter as TDFilter; try { filter[ALMUID] = uID.ToString(); } catch (Exception) { } List list = filter.NewList(); // filters out testset by UID if (list.Count == 1) { this.TestSet = new TestSetInstance(list[1] as TestSet, this.Username); } else { throw new CannotFindTestSet(CannotFindTestSet.ErrorMsg + uID); } return(this.TestSet); }
public bool UpdateField( int TestSetId, string FieldName, string Value) { bool returnValue = false; try { if (!Connect(ServerUrl, Username, Password, Domain, Project)) { Disconnect(); return(false); } TestSetFactory tsFact = tdc.TestSetFactory; TestSet tset = tsFact[TestSetId]; tset[FieldName] = Value; tset.Post(); returnValue = true; } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); } finally { Disconnect(); } return(returnValue); }
public TestSet GetTestSet(String path, String testSetName) { TestSetFactory testSetFactory = connection.TestSetFactory; TestSetTreeManager testSetTreeManager = connection.TestSetTreeManager; TestSetFolder testSetFolder = (TestSetFolder)testSetTreeManager.NodeByPath[path]; List testSetList = testSetFolder.FindTestSets(testSetName); TestSet testSet = testSetList[0]; return(testSet); }
public int Create( string DestinationPath, string TestSetName, string[] Additional = default(string[])) { int returnValue = 0; try { if (Connect(ServerUrl, Username, Password, Domain, Project)) { TestSetTreeManager tree = tdc.TestSetTreeManager; TestSetFolder folder; folder = tree.NodeByPath[DestinationPath]; TestSetFactory TSFact = folder.TestSetFactory; TestSet NewTestSet; NewTestSet = TSFact.AddItem(DBNull.Value); NewTestSet.Name = TestSetName; //Set additional field values if (Additional != default(string[])) { foreach (string fieldPair in Additional) { string[] tempFieldArray = fieldPair.Split(new[] { ";;" }, StringSplitOptions.None); NewTestSet[tempFieldArray[0]] = tempFieldArray[1]; } } NewTestSet.Post(); //Console.Out.WriteLine(NewTestSet.ID); returnValue = NewTestSet.ID; } } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); } finally { Disconnect(); } return(returnValue); }
/** * get a folder in QC * * @param string tsPath * @return TestSetFolder */ public TestSetFolder retrieveFolder(string tsPath) { TestSetFactory tsFactory = (TestSetFactory)tdConn.TestSetFactory; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)tdConn.TestSetTreeManager; TestSetFolder tsFolder = null; try { tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(tsPath); } catch (Exception e) { log.Warn("couldn't get TestSetFolder with path " + tsPath); log.Warn(e.Message); } return(tsFolder); }
//Given the test target machine name for calling RunTestSets public bool RunTestSets(string testMachine, string configPath) { try { TestSetTreeManager TestSetTreeMana = tdConn.TestSetTreeManager as TestSetTreeManager; TestSetFolder TestSetFolderPath = TestSetTreeMana.get_NodeByPath("Root\\AUTORUN\\" + tsFolderName) as TestSetFolder; TestSetFactory TestSetFact = TestSetFolderPath.TestSetFactory as TestSetFactory; TDFilter TestSetFilter = TestSetFact.Filter as TDFilter; List TestSetList = TestSetFilter.NewList() as List; foreach (TestSet ts in TestSetList) { // need give the testmachine name and notice the whether use QTP, // These value from command input if (testMachine != null && testMachine != "") { AutoLog.Info("[bool RunTestSets]Begin to run test set: " + ts.Name); //Console.Out.WriteLine("==========[bool RunTestSets]Begin to run test set: " + ts.Name); RunCurrentSet(ts, testMachine, configFile.RunParameter.UsingQTP, configPath); AutoLog.Info("[bool RunTestSets]End to run test set: " + ts.Name); //Console.Out.WriteLine("==========[bool RunTestSets]End run test set: " + ts.Name); } else { RunCurrentSet(ts, configFile.RunParameter.TestMachine, configFile.RunParameter.UsingQTP, configPath); } } return(true); } catch (Exception e) { AutoLog.Info("AutoIntSys: Run test sets exception" + e.Message); //Console.Out.WriteLine("AutoIntSys: Run test sets exception" + e.Message); //Debug.Print("AutoIntSys:" + e); //Debug.Print("AutoIntSys:Run Test Sets Error!"); return(false); } }
public static Object GetTSRunStatus(dynamic TSItem) { TestSetFactory TSetFact = mTDConn.TestSetFactory; TDFilter tsFilter = TSetFact.Filter; tsFilter["CY_CYCLE_ID"] = "" + TSItem.TestSetID + ""; List Testset = TSetFact.NewList(tsFilter.Text); foreach (TestSet testset in Testset) { if (testset.Name == TSItem.TestSetName) { TSTestFactory TSTestFact = testset.TSTestFactory; TDFilter tsTestFilter = TSetFact.Filter; tsTestFilter["TC_CYCLE_ID"] = "" + TSItem.TestSetID + ""; List TSActivities = TSTestFact.NewList(tsTestFilter.Text); foreach (TSTest tst in TSActivities) { bool existing = false; foreach (string[] status in TSItem.TestSetStatuses) { if (status[0] == tst.Status) { existing = true; status[1] = (Int32.Parse(status[1]) + 1).ToString(); } } if (!existing) { TSItem.TestSetStatuses.Add(new string[] { tst.Status, "1" }); } } } } return(TSItem); }
//get test set explorer(tree view) public static IEnumerable <Object> GetTestSetExplorer(string PathNode) { TestSetTreeManager treeM = (TestSetTreeManager)mTDConn.TestSetTreeManager; TestSetFolder tsFolder = treeM.get_NodeByPath(PathNode); if (tsFolder == null && PathNode.ToUpper() == "ROOT") { tsFolder = treeM.Root; } TestSetFactory TSetFact = mTDConn.TestSetFactory; TDFilter tsFilter = TSetFact.Filter; try { tsFilter["CY_FOLDER_ID"] = "" + tsFolder.NodeID + ""; } catch (Exception e) { tsFilter["CY_FOLDER_ID"] = "\"" + tsFolder.Path.ToString() + "\""; Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {e.Message}", e); } List TestsetList = TSetFact.NewList(tsFilter.Text); List <ALMTestSetSummary> testlabPathList = new List <ALMTestSetSummary>(); foreach (TestSet testset in TestsetList) { ALMTestSetSummary QCTestSetTreeItem = new ALMTestSetSummary(); QCTestSetTreeItem.TestSetID = testset.ID; QCTestSetTreeItem.TestSetName = testset.Name; testlabPathList.Add(QCTestSetTreeItem); } return(testlabPathList); }
public static bool ExportBusinessFlowToQC(BusinessFlow businessFlow, TestSet mappedTestSet, string uploadPath, ObservableList <ExternalItemFieldBase> testSetFields, ref string result) { TestSet testSet; ObservableList <ActivitiesGroup> existingActivitiesGroups = new ObservableList <ActivitiesGroup>(); try { if (mappedTestSet == null) { //##create new Test Set in QC TestSetFactory TestSetF = (TestSetFactory)mTDConn.TestSetFactory; testSet = (TestSet)TestSetF.AddItem(System.DBNull.Value); //set the upload path TestSetTreeManager treeM = (TestSetTreeManager)mTDConn.TestSetTreeManager; ISysTreeNode testSetParentFolder = (ISysTreeNode)treeM.get_NodeByPath(uploadPath); testSet.TestSetFolder = testSetParentFolder.NodeID; } else { //##update existing test set //testSet = mappedTestSet; testSet = ImportFromQC.GetQCTestSet(mappedTestSet.ID.ToString()); TSTestFactory testsF = (TSTestFactory)testSet.TSTestFactory; List tsTestsList = testsF.NewList(""); foreach (TSTest tsTest in tsTestsList) { ActivitiesGroup ag = businessFlow.ActivitiesGroups.Where(x => (x.ExternalID == tsTest.TestId.ToString() && x.ExternalID2 == tsTest.ID.ToString())).FirstOrDefault(); if (ag == null) { testsF.RemoveItem(tsTest.ID); } else { existingActivitiesGroups.Add(ag); } } } //set item fields foreach (ExternalItemFieldBase field in testSetFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { testSet[field.ID] = field.SelectedValue; } else { try { testSet[field.ID] = "NA"; } catch { } } } } //post the test set testSet.Name = businessFlow.Name; try { testSet.Post(); } catch (Exception ex) { if (ex.Message.Contains("The Test Set already exists")) { result = "Cannot export " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + "- The Test Set already exists in the selected folder. "; Reporter.ToLog(eLogLevel.ERROR, result, ex); return(false); } //Searching for the testset in case it was created in ALM although getting exception TestSetFactory TSetFact = mTDConn.TestSetFactory; TDFilter tsFilter = TSetFact.Filter; TestSetTreeManager treeM = (TestSetTreeManager)mTDConn.TestSetTreeManager; ISysTreeNode testSetParentFolder = (ISysTreeNode)treeM.get_NodeByPath(uploadPath); try { tsFilter["CY_FOLDER_ID"] = "" + testSetParentFolder.NodeID + ""; } catch (Exception e) { tsFilter["CY_FOLDER_ID"] = "\"" + testSetParentFolder.Path.ToString() + "\""; Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {e.Message}", e); } List TestsetList = TSetFact.NewList(tsFilter.Text); foreach (TestSet set in TestsetList) { if (set.Name == businessFlow.Name) { testSet = set; break; } } } businessFlow.ExternalID = testSet.ID.ToString(); //Add missing test cases TSTestFactory testCasesF = testSet.TSTestFactory; foreach (ActivitiesGroup ag in businessFlow.ActivitiesGroups) { if (existingActivitiesGroups.Contains(ag) == false && string.IsNullOrEmpty(ag.ExternalID) == false && ImportFromQC.GetQCTest(ag.ExternalID) != null) { TSTest tsTest = testCasesF.AddItem(ag.ExternalID); if (tsTest != null) { ag.ExternalID2 = tsTest.ID;//the test case instance ID in the test set- used for exporting the execution details } } else { foreach (ActivityIdentifiers actIdent in ag.ActivitiesIdentifiers) { ExportActivityAsTestStep(ImportFromQC.GetQCTest(ag.ExternalID), (Activity)actIdent.IdentifiedActivity); } } } return(true); } catch (Exception ex) { result = "Unexpected error occurred- " + ex.Message; Reporter.ToLog(eLogLevel.ERROR, "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " to QC/ALM", ex); return(false); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { TDConnection tdConn = new TDConnection(); tdConn.InitConnectionEx(qcUrl.Text); tdConn.ConnectProjectEx(qcDomain.Text, qcProject.Text, qcLogin.Text, qcPassword.Password); //MessageBox.Show((string)qcUrl.Text); //MessageBox.Show((string)qcDomain.Text); //MessageBox.Show((string)qcProject.Text); //MessageBox.Show((string)qcLogin.Text); //MessageBox.Show((string)qcPassword.Password); //MessageBox.Show((string)qcDomain.Text); //MessageBox.Show((string)testFolder.Text); //MessageBox.Show((string)testSet.Text); //RunFactory runFactory = (RunFactory)test.RunFactory;// //string testFolder = "^" + @"Root\MULTUM\Monthly Testing\SDK v4\"; //string testSet = "BNF SDKv4 Server and Update"; TestSetFactory tsFactory = (TestSetFactory)tdConn.TestSetFactory; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)tdConn.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder.Text); TDAPIOLELib.List tsList = (TDAPIOLELib.List)tsFolder.FindTestSets((string)testSet.Text, false, null); //TDAPIOLELib.List tsTestList = tsFactory.NewList(""); //List tsList = tsFolder.FindTestSets(testSet, false, "status=No Run"); //Feature\Multum\Black Box\Monthly Testing\SDK v4 foreach (TestSet testset in tsList) { Console.WriteLine("Test Set Folder Path: {0}", testFolder); Console.WriteLine("Test Set: {0}", testset.Name); TestSetFolder tsfolder = (TestSetFolder)testset.TestSetFolder; //string testFolder = "^" + @"Root\MULTUM\Monthly Testing\SDK v4\"; TSTestFactory tsTestFactory = (TSTestFactory)testset.TSTestFactory; TDAPIOLELib.List tsTestList = tsTestFactory.NewList(""); //} foreach (TSTest tsTest in tsTestList)//no such interface supported { Console.WriteLine("Test Set: {0}", tsTest.Name); //Console.ReadLine(); string status = (string)tsTest.Status; Console.WriteLine("STATUS {0}", status); //Console.WriteLine("PARAMS {0}",tsTest.Params); Console.WriteLine("PARAMS {0}", tsTest.History); TDAPIOLELib.Run lastRun = (TDAPIOLELib.Run)tsTest.LastRun; // don't update test if it may have been modified by someone else if (lastRun == null) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; TDAPIOLELib.List runs = runFactory.NewList(""); Console.WriteLine("test runs: {0}", runs.Count); String date = DateTime.Now.ToString("MM-dd_hh-mm-ss"); TDAPIOLELib.Run run = (TDAPIOLELib.Run)runFactory.AddItem("Run_" + date); //Run_5-23_14-49-52 var oRunInstance = (RunFactory)tsTest.RunFactory; //var oRun = (Run)oRunInstance.AddItem("Performance Test"); //run.Status = "Passed"; //run.Post(); //run.Refresh(); var oTest = (Test)tsTest.Test; var tsDesignStepList = oTest.DesignStepFactory.NewList(""); var oStepFactory = (StepFactory)run.StepFactory; foreach (DesignStep oDesignStep in tsDesignStepList) { var oStep = (Step)oStepFactory.AddItem(oDesignStep.StepName); //oStep.Status = "Passed"; //oStep.Post(); } } } } tdConn.DisconnectProject(); tdConn.Disconnect(); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
public int Copy( string DestinationPath, string TestSetName, int TemplateTestSetId) { int returnValue = 0; try { if (!Connect(ServerUrl, Username, Password, Domain, Project)) { Disconnect(); return(0); } if (!CanPerformAction("ac_copy_cycle")) { rr.AddErrorLine("Error: user has no permission to copy a test set"); Disconnect(); return(0); } ISupportCopyPaste4 iscp; string clipboard; TestSetFactory testSetFact; TestSetTreeManager treeMan = tdc.TestSetTreeManager; TestSetFolder folder = null; folder = treeMan.NodeByPath[DestinationPath]; testSetFact = tdc.TestSetFactory; iscp = (ISupportCopyPaste4)testSetFact; clipboard = iscp.CopyToClipBoard(TemplateTestSetId.ToString(), 0, ""); try { iscp.PasteFromClipBoard(clipboard, folder.NodeID.ToString(), 0, 1); } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); //An exception happens when the name is already taken. The TS will copy successfully. } TDFilter filter; TestSetFactory tsFact = folder.TestSetFactory; filter = tsFact.Filter; string tsName = tsFact[TemplateTestSetId].Name; tsName = tsName.Trim(' '); string filterString = "\"" + "*" + tsName + "*" + "\""; filter["CY_CYCLE"] = filterString; filter.OrderDirection["CY_CYCLE_ID"] = (short)TDAPI_FILTERORDER.TDOLE_DESCENDING; List testSetList = filter.NewList(); //Because of an ALM API bug, the OrderDirection doesn't always work, so we have to iterate manually to find the newly created TS int newestId = 0; TestSet newCopy; foreach (TestSet newTestSet in testSetList) { if (newTestSet.ID > newestId) { newestId = newTestSet.ID; } } newCopy = tsFact[newestId]; newCopy.Name = TestSetName; try { newCopy.Post(); } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); } returnValue = newCopy.ID; //Console.Out.WriteLine(returnValue); } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); } finally { Disconnect(); } return(returnValue); }
public bool Attach( int TestSetId, AttachmentType Type, string Path, string Description = default(string), string Name = default(string)) { bool success = false; try { if (!Connect(ServerUrl, Username, Password, Domain, Project)) { return(false); } TestSetFactory tsFact = tdc.TestSetFactory; TestSet tSet = tsFact[TestSetId]; string tSetName = tSet.Name; //Strange ALM bug allows you to select a non existant tet set. Calling name ensures it exists AttachmentFactory attachFact = tSet.Attachments; Attachment attach = attachFact.AddItem(DBNull.Value); attach.FileName = Path; TDAPI_ATTACH_TYPE attachType = TDAPI_ATTACH_TYPE.TDATT_FILE; switch (Type) { case AttachmentType.File: case AttachmentType.file: attachType = TDAPI_ATTACH_TYPE.TDATT_FILE; break; case AttachmentType.URL: case AttachmentType.url: case AttachmentType.Url: attachType = TDAPI_ATTACH_TYPE.TDATT_INTERNET; break; } attach.Type = (int)attachType; if (Description != default(string)) { attach.Description = Description; } //Post will fail if attachment path is bad attach.Post(); if ((Name != default(string)) && (attachType == TDAPI_ATTACH_TYPE.TDATT_FILE)) { attach.Rename(Name); attach.Post(); } success = true; } catch (COMException ce) { //If we get an error, delete the attachment //If the file path is invalid and the attachment never uploads, ALM throws an error but posts the attachment anyways //returning no attachment object. So the only way to detect this is to look for 0 sized attachments and delete them TestSetFactory tsFact = tdc.TestSetFactory; TestSet tSet = tsFact[TestSetId]; AttachmentFactory attachFact = tSet.Attachments; List attachList = attachFact.NewList(""); foreach (Attachment a in attachList) { if (a.FileSizeEx == 0) { attachFact.RemoveItem(a.ID); } } rr.AddErrorLine(HandleException(ce)); } finally { Disconnect(); } return(success); }
public int AddTest( int TestSetId, int TestConfigId, string[] Additional = default(string[]), bool RemoveTestOnUpdateFail = default(bool)) { int result = 0; try { if (!Connect(ServerUrl, Username, Password, Domain, Project)) { return(0); } //Get the test ID from the config factory TestConfigFactory TestConfigFact = tdc.TestConfigFactory; TestConfig TestConfig = TestConfigFact[TestConfigId]; int TestId = TestConfig.TestId; //API provides no way to add a specific test configuration to the test set //Instead we will add the test to the test set then remove the unneeded instances TestSetFactory TSFact = tdc.TestSetFactory; TestSet TestSet = TSFact[TestSetId]; TSTestFactory TSTestFact = TestSet.TSTestFactory; //Capture the starting list of tests in the test set List StartingTestList = TSTestFact.NewList(""); System.Collections.Generic.List <int> StartingTestInstanceList = new List <int>(); foreach (TSTest testInstance in StartingTestList) { StartingTestInstanceList.Add(int.Parse(testInstance.ID)); } //Add the test to the test set TSTestFact.AddItem(TestId); //Capture the new list of tests in the test set List EndingTestList = TSTestFact.NewList(""); System.Collections.Generic.List <int> EndingTestInstanceList = new List <int>(); foreach (TSTest testInstance in EndingTestList) { EndingTestInstanceList.Add(int.Parse(testInstance.ID)); } //Remove added tests that we don't want TSTest tempInstance, addedTestInstance = null; TestConfig tempConfig; foreach (int testInstanceId in EndingTestInstanceList) { if (!StartingTestInstanceList.Contains(testInstanceId)) { tempInstance = TSTestFact[testInstanceId]; tempConfig = tempInstance.TestConfiguration; if (!TestConfigId.Equals(tempConfig.ID)) { TSTestFact.RemoveItem(tempInstance.ID); } else { addedTestInstance = tempInstance; } } } result = int.Parse(addedTestInstance.ID); //Set additional field values if (Additional != default(string[])) { foreach (string fieldPair in Additional) { string[] tempFieldArray = fieldPair.Split(new[] { ";;" }, StringSplitOptions.None); addedTestInstance[tempFieldArray[0]] = tempFieldArray[1]; } addedTestInstance.Post(); } } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); if (RemoveTestOnUpdateFail && result > 0) { TSTestFactory fact = tdc.TSTestFactory; fact.RemoveItem(result); result = 0; } } Disconnect(); return(result); }
public int Create( int TestSetId, int TestConfigId, TestStatus Status, string RunName, bool DraftRun, string[] Additional = default(string[])) { int runId = 0; try { if (!Connect(ServerUrl, Username, Password, Domain, Project)) { return(0); } if (!CanPerformAction("ac_run_manual_test")) { rr.AddErrorLine("Error: The user does not have permission to execute tests"); return(0); } string runStatus = NormalizeTestStatus(Status); TestSetFactory tsFact = tdc.TestSetFactory; TestSet targetTestSet = tsFact[TestSetId]; TSTestFactory tsTestFactory = targetTestSet.TSTestFactory; TDFilter filter = tsTestFactory.Filter; filter["TC_TEST_CONFIG_ID"] = TestConfigId.ToString(); List testInstanceList = filter.NewList(); if (testInstanceList.Count == 1) { TSTest testInstance = testInstanceList[1]; RunFactory runFact = testInstance.RunFactory; //Best practice is to provide a null value, but an ALM bug keeps the test status of the test instance unchanged unless a name is provided Run testRun = runFact.AddItem(RunName + "_" + DateTime.Now); testRun.Status = runStatus; if (DraftRun) { testRun["RN_DRAFT"] = "Y"; } //Set additional field values if (Additional != default(string[])) { foreach (string fieldPair in Additional) { string[] tempFieldArray = fieldPair.Split(new[] { ";;" }, StringSplitOptions.None); testRun[tempFieldArray[0]] = tempFieldArray[1]; } } testRun.Post(); runId = testRun.ID; //Console.Out.WriteLine(runId); } else if (testInstanceList.Count == 0) { rr.AddErrorLine("Error: The test configuration ID does not exist in the test set."); } else { //More than one instace of the test configuration exists in the test set //The integration cannot support duplicates rr.AddErrorLine("Error: multiple instances of the test configuration exist in this test set."); } } catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); } finally { Disconnect(); } return(runId); }
private TestSetFolder CreateTestSetNames(List <string> TestSetNames, TestSetFolder TSFolder) { List <ItemValue> tcList = new List <ItemValue>(); #region Generate TestSet Name //Get all match test cases and store it to a List try { ICommand com = tdConn.Command as ICommand; string[] columnName = { "TS_TEST_ID", configFile.CaseFilter.TestSetName }; string sqlCommand = GenerateSQLText(columnName); com.CommandText = sqlCommand; IRecordset recList = com.Execute() as IRecordset; recList.First(); for (int num = 0; num < recList.RecordCount; num++) { ItemValue tc = new ItemValue(); tc.Test_ID = recList["TS_TEST_ID"].ToString(); if (recList[configFile.CaseFilter.TestSetName] != null) { tc.Test_Custom = recList[configFile.CaseFilter.TestSetName].ToString(); } tcList.Insert(0, tc); recList.Next(); } } catch (Exception e) { AutoLog.Info("AutoIntSys: Exception with " + e.Message); AutoLog.Info("AutoIntSys: Fail to get Specified Field Value from TEST Table!"); //Debug.Print("AutoIntSys:Fail to get Specified Field Value from TEST Table!"); //Debug.Print("AutoIntSys:" + e); return(null); } #endregion #region Generate TestSet try { TestSetFactory TSFact = TSFolder.TestSetFactory as TestSetFactory; TestFactory TestFact = tdConn.TestFactory as TestFactory; foreach (string TSName in TestSetNames) { TestSet TestSetName; TSTestFactory TSTestFact; TestSetName = TSFact.AddItem(TSName) as TestSet; TestSetName.Post(); TSTestFact = TestSetName.TSTestFactory as TSTestFactory; foreach (ItemValue t in tcList) { if (t.Test_Custom == TSName) { TSTestFact.AddItem(t.Test_ID); } } } createTSSucess = true; return(TSFolder); } catch (Exception e) { AutoLog.Info("AutoIntSys: Exception with " + e.Message); AutoLog.Info("AutoIntSys: Create Test Sets Error!"); //Debug.Print("AutoIntSys:Create Test Sets Error!"); //Debug.Print("AutoIntSys:" + e.Message); return(null); } #endregion }
public void UploadResults(TestCase currentTestCase) { string testFolder = Convert.ToString(ExecutionSession.dictCommonData["QCFolder"]); string testSetName = currentTestCase.Category; TestSetFactory tsFactory = (TestSetFactory)qcConnect.TestSetFactory; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)qcConnect.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder); List tsList = tsFolder.FindTestSets(testSetName, false, null); TestSet testSet = tsList[1]; tsFolder = (TestSetFolder)testSet.TestSetFolder; TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory; List tsTestList = tsTestFactory.NewList(""); // And finally, update each test case status: foreach (TSTest tsTest in tsTestList) { if (currentTestCase.TestCaseName == tsTest.Name.Remove(0, 3)) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; List allfields = runFactory.Fields; String browserValue = tsTest["TC_USER_TEMPLATE_10"]; Run lastRun = (Run)tsTest.LastRun; string runName = runFactory.UniqueRunName; RunFactory objRunFactory = tsTest.RunFactory; Run theRun = objRunFactory.AddItem(runName); theRun.Name = runName; theRun.CopyDesignSteps(); StepFactory Step = theRun.StepFactory; List stepList = (List)Step.NewList(""); if (currentTestCase.OverAllResult == OverAllResult.PASS) { theRun.Status = "Passed"; } else { theRun.Status = "Failed"; } theRun.Post(); //Delete current attachment from QC test set test case AttachmentFactory objAttachmentFactory = tsTest.Attachments; var objCurrentAttachments = objAttachmentFactory.NewList(""); for (int objC = 1; objC <= objCurrentAttachments.Count; objC++) { try { objAttachmentFactory.RemoveItem(tsTest.Attachments.NewList("").Item(1).ID); } catch { } } IAttachment objAttachment = objAttachmentFactory.AddItem(DBNull.Value); objAttachment.FileName = currentTestCase.QCHTMLReportPath; objAttachment.Type = 1; objAttachment.Post(); string[] filePaths = System.IO.Directory.GetFiles(currentTestCase.QCScreenShotPath); foreach (string file in filePaths) { objAttachment = objAttachmentFactory.AddItem(DBNull.Value); objAttachment.FileName = file; objAttachment.Type = 1; objAttachment.Post(); } break; } } }
public void UploadResults(TB2.TestCase currentTestCase) { string testFolder = @"Root\WCS 7up Core - 5022\zz Automation\PracticeExecution\Temp_Prashant\QA72_7_31"; string testSetName = currentTestCase.Category; TestSetFactory tsFactory = (TestSetFactory)qcConnect.TestSetFactory; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)qcConnect.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder); List tsList = tsFolder.FindTestSets(testSetName, false, null); TestSet testSet = tsList[1]; //foreach (TestSet testSet in tsList) //{ tsFolder = (TestSetFolder)testSet.TestSetFolder; TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory; List tsTestList = tsTestFactory.NewList(""); // And finally, update each test case status: foreach (TSTest tsTest in tsTestList) { //System.Console.Out.WriteLine("Test Case ID: " + tsTest.ID + ", Test Case Name: " + tsTest.Name + "\n"); if (currentTestCase.TestCaseName == tsTest.Name.Remove(0, 3)) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; List allfields = runFactory.Fields; String browserValue = tsTest["TC_USER_TEMPLATE_10"]; // Console.WriteLine("Browser value : " + browserValue); Run lastRun = (Run)tsTest.LastRun; string runName = runFactory.UniqueRunName; RunFactory objRunFactory = tsTest.RunFactory; Run theRun = objRunFactory.AddItem(runName); theRun.Name = runName; //Get the count of test steps and compare it with the number of steps that were actually executed //and define the Execution status accordinagly theRun.CopyDesignSteps(); StepFactory Step = theRun.StepFactory; List stepList = (List)Step.NewList(""); if (currentTestCase.OverAllResult == OverAllResult.PASS) { theRun.Status = "Passed"; } else { theRun.Status = "Failed"; } theRun.Post(); //Delete current attachment from QC test set test case AttachmentFactory objAttachmentFactory = tsTest.Attachments; objSkipExec: var objCurrentAttachments = objAttachmentFactory.NewList(""); for (int objC = 1; objC <= objCurrentAttachments.Count; objC++) { try { objAttachmentFactory.RemoveItem(tsTest.Attachments.NewList("").Item(1).ID); } catch { } } if (objAttachmentFactory.NewList("").Count > 0) { goto objSkipExec; } IAttachment objAttachment = objAttachmentFactory.AddItem(DBNull.Value); objAttachment.FileName = currentTestCase.HTMLReportPath; objAttachment.Type = 1; objAttachment.Post(); string[] filePaths = System.IO.Directory.GetFiles(currentTestCase.ScreenShotPath); foreach (string file in filePaths) { objAttachment = objAttachmentFactory.AddItem(DBNull.Value); objAttachment.FileName = file; objAttachment.Type = 1; objAttachment.Post(); } break; // } } } }