Beispiel #1
0
        private void UploadALM(string strSelectedScriptName, string strStatus, string strFailureReason, string strJenkinsLog)
        {
            string strSelectedTestSetName = treeViewALM.SelectedNode.Name;

            string             strSelectedTestSetFullPath = BuildPath(treeViewALM.SelectedNode);;
            TestSetTreeManager testSetTreeMgr             = (TestSetTreeManager)conn.TestSetTreeManager;
            TestSetFolder      rootTestSetFolder          = (TestSetFolder)testSetTreeMgr.get_NodeByPath(strSelectedTestSetFullPath);
            List        testSetList = rootTestSetFolder.FindTestSets(strSelectedTestSetName, false, string.Empty);
            IEnumerator enumerator  = testSetList.GetEnumerator();;

            if (enumerator.MoveNext())
            {
                TestSet       testSet       = (TestSet)enumerator.Current;
                TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory;
                ListClass     testList      = (ListClass)tsTestFactory.NewList(string.Empty);

                IEnumerator testListEnum = testList.GetEnumerator();
                while (testListEnum.MoveNext())
                {
                    object item  = testListEnum.Current;
                    TSTest atest = (TSTest)testListEnum.Current;
                    if (atest.TestName.ToLower() == strSelectedScriptName.ToLower())
                    {
                        atest.Status        = strStatus;
                        atest["TC_USER_01"] = strFailureReason;
                        atest["TC_USER_09"] = strJenkinsLog;
                        atest.Post();
                    }
                }
            }
        }
Beispiel #2
0
        private void treeViewALM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.ToString().ToLower() == "testset")
                {
                    TestSetTreeManager testSetTreeMgr = (TestSetTreeManager)conn.TestSetTreeManager;

                    var           path = BuildPath(e.Node);
                    TestSetFolder rootTestSetFolder = (TestSetFolder)testSetTreeMgr.get_NodeByPath(path);
                    List          testSetList       = rootTestSetFolder.FindTestSets(e.Node.Text, false, string.Empty);
                    IEnumerator   enumerator        = testSetList.GetEnumerator();
                    if (enumerator.MoveNext())
                    {
                        TestSet       testSet       = (TestSet)enumerator.Current;
                        TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory;
                        ListClass     testList      = (ListClass)tsTestFactory.NewList(string.Empty);

                        IEnumerator testListEnum = testList.GetEnumerator();
                        if (dtALMTestDetails == null)
                        {
                            dtALMTestDetails = BuildDataTable();
                        }
                        else
                        {
                            dtALMTestDetails.Clear();
                        }
                        List TSSetFields = tsTestFactory.Fields;
                        while (testListEnum.MoveNext())
                        {
                            DataRow drTestDetails = dtALMTestDetails.NewRow();
                            object  item          = testListEnum.Current;
                            TSTest  atest         = (TSTest)testListEnum.Current;

                            drTestDetails["TestName"]      = atest.TestName;
                            drTestDetails["Status"]        = atest.Status;
                            drTestDetails["FailureReason"] = atest["TC_USER_01"];
                            drTestDetails["JenkinsLog"]    = atest["TC_USER_09"];

                            dtALMTestDetails.Rows.Add(drTestDetails);
                        }
                    }

                    dgvALM.DataSource = dtALMTestDetails;
                }
                else
                {
                    dtALMTestDetails.Clear();
                    dgvALM.DataSource = dtALMTestDetails;
                }
            }
            else
            {
                dtALMTestDetails.Clear();
                dgvALM.DataSource = dtALMTestDetails;
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #3
0
        private void CreateTestInstance(TestSet ts, List <string> TestID)
        {
            TSTestFactory tsF = ts.TSTestFactory as TSTestFactory;

            foreach (string id in TestID)
            {
                TSTest TestInstance = tsF.AddItem(id) as TSTest;
                TestInstance.Post();
            }
        }
Beispiel #4
0
        public void CreateTestInstance(string TestSetFolderPath, string testsetName, List <string> TestID)
        {
            TestSet       ts  = CreateTestSet_Internal(TestSetFolderPath, testsetName);
            TSTestFactory tsF = ts.TSTestFactory as TSTestFactory;

            foreach (string id in TestID)
            {
                TSTest TestInstance = tsF.AddItem(id) as TSTest;
                TestInstance.Post();
            }
        }
        /**
         * set status for a single test and update in QC
         *
         * @param TSTest test - the test to be updated
         * @param string status - "Passed", "Failed", etc.
         */
        public void recordTestResult(TSTest test, string status)
        {
            string testInfo = DELIM + DELIM + DELIM +
                              "TestId: " + test.TestId + DELIM +
                              "TestName: " + test.TestName + DELIM +
                              "";

            Run lastRun = (Run)test.LastRun;

            if (lastRun != null)
            {
                testInfo += lastRun.Name + DELIM + lastRun.Status;
            }

            log.Debug(testInfo);

            RunFactory runFactory = (RunFactory)test.RunFactory;
            String     date       = DateTime.Now.ToString("yyyyMMddhhmmss");
            Run        run        = (Run)runFactory.AddItem("Run" + date);

            run.Status = status;
            run.Post();
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        public static bool ExportExecutionDetailsToQC(BusinessFlow bizFlow, ref string result, PublishToALMConfig publishToALMConfig = null)
        {
            result = string.Empty;
            if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID";
                return(false);
            }

            try
            {
                //get the BF matching test set
                TestSet testSet = ImportFromQC.GetQCTestSet(bizFlow.ExternalID);//bf.externalID holds the TestSet TSTests collection id
                if (testSet != null)
                {
                    //get the Test set TC's
                    List <TSTest> qcTSTests = ImportFromQC.GetTSTestsList(testSet); //list of TSTest's on main TestSet in TestLab

                    //get all BF Activities groups
                    ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups;
                    if (activGroups.Count > 0)
                    {
                        foreach (ActivitiesGroup activGroup in activGroups)
                        {
                            if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) ||
                                (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) ||
                                publishToALMConfig.FilterStatus == FilterByStatus.All)
                            {
                                TSTest tsTest = null;
                                //go by TC ID = TC Instance ID
                                tsTest = qcTSTests.Where(x => x.TestId == activGroup.ExternalID && x.ID == activGroup.ExternalID2).FirstOrDefault();
                                if (tsTest == null)
                                {
                                    //go by Linked TC ID + TC Instance ID
                                    tsTest = qcTSTests.Where(x => ImportFromQC.GetTSTestLinkedID(x) == activGroup.ExternalID && x.ID == activGroup.ExternalID2).FirstOrDefault();
                                }
                                if (tsTest == null)
                                {
                                    //go by TC ID
                                    tsTest = qcTSTests.Where(x => x.TestId == activGroup.ExternalID).FirstOrDefault();
                                }
                                if (tsTest != null)
                                {
                                    //get activities in group
                                    List <Activity> activities   = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList();
                                    string          TestCaseName = PathHelper.CleanInValidPathChars(tsTest.TestName);
                                    if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty))
                                    {
                                        String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                                        publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp;
                                    }

                                    RunFactory runFactory = (RunFactory)tsTest.RunFactory;
                                    Run        run        = (Run)runFactory.AddItem(publishToALMConfig.VariableForTCRunNameCalculated);

                                    // Attach ActivityGroup Report if needed
                                    if (publishToALMConfig.ToAttachActivitiesGroupReport)
                                    {
                                        if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                            (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                                        {
                                            //Creating the Zip file - start
                                            string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                            string zipFileName   = targetZipPath + "\\" + TestCaseName.ToString() + "_GingerHTMLReport.zip";

                                            if (!System.IO.File.Exists(zipFileName))
                                            {
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            else
                                            {
                                                System.IO.File.Delete(zipFileName);
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                            //Creating the Zip file - finish
                                            //Attaching Zip file - start
                                            AttachmentFactory      attachmentFactory = (AttachmentFactory)run.Attachments;
                                            TDAPIOLELib.Attachment attachment        = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value);
                                            attachment.Description = "TC Ginger Execution HTML Report";
                                            attachment.Type        = 1;
                                            attachment.FileName    = zipFileName;
                                            attachment.Post();

                                            //Attaching Zip file - finish
                                            System.IO.File.Delete(zipFileName);
                                        }
                                    }


                                    //create run with activities as steps
                                    run.CopyDesignSteps();
                                    run.Post();
                                    StepFactory stepF     = run.StepFactory;
                                    List        stepsList = stepF.NewList("");

                                    //int i = 0;
                                    int index = 1;
                                    foreach (Step step in stepsList)
                                    {
                                        //search for matching activity based on ID and not order, un matching steps need to be left as No Run
                                        int      stepDesignID     = (stepsList[index]).Field("ST_DESSTEP_ID");
                                        Activity matchingActivity = activities.Where(x => x.ExternalID == stepDesignID.ToString()).FirstOrDefault();
                                        if (matchingActivity != null)
                                        {
                                            switch (matchingActivity.Status)
                                            {
                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed:
                                                step.Status = "Failed";
                                                List <IAct> failedActs = matchingActivity.Acts.Where(x => x.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed).ToList();
                                                string      errors     = string.Empty;
                                                foreach (Act act in failedActs)
                                                {
                                                    errors += act.Error + Environment.NewLine;
                                                }
                                                step["ST_ACTUAL"] = errors;
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.NA:
                                                step.Status       = "N/A";
                                                step["ST_ACTUAL"] = "NA";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed:
                                                step.Status       = "Passed";
                                                step["ST_ACTUAL"] = "Passed as expected";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped:
                                                //step.Status = "No Run";
                                                step.Status       = "N/A";
                                                step["ST_ACTUAL"] = "Skipped";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending:
                                                step.Status       = "No Run";
                                                step["ST_ACTUAL"] = "Was not executed";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Running:
                                                step.Status       = "Not Completed";
                                                step["ST_ACTUAL"] = "Not Completed";
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            //Step not exist in Ginger so left as "No Run" unless it is step data
                                            if (step.Name.ToUpper() == "STEP DATA")
                                            {
                                                step.Status = "Passed";
                                            }
                                            else
                                            {
                                                step.Status = "No Run";
                                            }
                                        }
                                        step.Post();
                                        index++;
                                    }

                                    //get all execution status for all steps
                                    ObservableList <string> stepsStatuses = new ObservableList <string>();
                                    foreach (Step step in stepsList)
                                    {
                                        stepsStatuses.Add(step.Status);
                                    }

                                    //update the TC general status based on the activities status collection.
                                    if (stepsStatuses.Where(x => x == "Failed").Count() > 0)
                                    {
                                        run.Status = "Failed";
                                    }
                                    else if (stepsStatuses.Where(x => x == "No Run").Count() == stepsList.Count || stepsStatuses.Where(x => x == "N/A").Count() == stepsList.Count)
                                    {
                                        run.Status = "No Run";
                                    }
                                    else if (stepsStatuses.Where(x => x == "Passed").Count() == stepsList.Count || (stepsStatuses.Where(x => x == "Passed").Count() + stepsStatuses.Where(x => x == "N/A").Count()) == stepsList.Count)
                                    {
                                        run.Status = "Passed";
                                    }
                                    else
                                    {
                                        run.Status = "Not Completed";
                                    }
                                    run.Post();
                                }
                                else
                                {
                                    //No matching TC was found for the ActivitiesGroup in QC
                                    result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in QC/ALM.";
                                }
                            }
                        }
                    }
                    else
                    {
                        //No matching Test Set was found for the BF in QC
                        result = "No matching Test Set was found in QC/ALM.";
                    }
                }
                if (result == string.Empty)
                {
                    result = "Export performed successfully.";
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to QC/ALM", ex);
                //if (!silentMode)
                //    Reporter.ToUser(eUserMsgKey.ErrorWhileExportingExecDetails, ex.Message);
                return(false);
            }
        }
        /**
         * set status for a single test and update in QC
         *
         * @param TSTest test - the test to be updated
         * @param string status - "Passed", "Failed", etc.
         */
        public void recordTestResult(TSTest test, string status)
        {
            string testInfo = DELIM + DELIM + DELIM +
                "TestId: " + test.TestId + DELIM +
                "TestName: " + test.TestName + DELIM +
                "";

            Run lastRun = (Run)test.LastRun;
            if (lastRun != null)
            {
                testInfo += lastRun.Name + DELIM + lastRun.Status;
            }

            log.Debug(testInfo);

            RunFactory runFactory = (RunFactory)test.RunFactory;
            String date = DateTime.Now.ToString("yyyyMMddhhmmss");
            Run run = (Run)runFactory.AddItem("Run" + date);
            run.Status = status;
            run.Post();
        }
        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);
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
 public void RunTest(TSTest test, string result)
 {
     var runFactory=test.RunFactory as RunFactory;
     var now = DateTime.Now;
     var run = runFactory.AddItem("Run_"+now.ToShortDateString()+"_"+now.ToShortTimeString()) as Run;
     run.Status = result;
     run.Post();
     run.Refresh();
 }
Beispiel #12
0
        public bool Add(string TestSetFolderPath, string testsetName, string testName, string runName, string status, string _attachmentPath, string _attachmentName, string installogPath, string installlogName, List <RunSteps> steps)
        {
            TestSetFactory     TestSetFact;
            TestSetTreeManager tsTreeMgr;
            TestSetFolder      tSetFolder;
            List     lst;
            TDFilter TestFilter;
            Run      therun;

            tsTreeMgr  = tdconn.TestSetTreeManager as TestSetTreeManager;
            tSetFolder = tsTreeMgr.Root as TestSetFolder;

            tSetFolder = tsTreeMgr.get_NodeByPath(TestSetFolderPath) as TestSetFolder;



            TestSetFact            = tSetFolder.TestSetFactory as TestSetFactory;
            TestFilter             = TestSetFact.Filter as TDFilter;
            TestFilter["CY_CYCLE"] = "'" + testsetName + "'";

            lst = TestSetFact.NewList(TestFilter.Text); // list index from 1

            TestSet ts = lst[1] as TestSet;


            TestFilter.Clear();



            TSTestFactory tsF = ts.TSTestFactory as TSTestFactory;

            TestFilter            = tsF.Filter as TDFilter;
            TestFilter["TS_NAME"] = "'" + testName + "'";

            TSTest TestInstance = tsF.NewList(TestFilter.Text)[1] as TSTest;


            RunFactory rf      = TestInstance.RunFactory as RunFactory;
            List       runlist = rf.NewList("");

            //update run is run exist
            for (int index = 1; index <= runlist.Count; index++)
            {
                therun = runlist[index] as Run;
                if (therun.Name == runName)
                {
                    foreach (RunSteps runstep in steps)
                    {
                        runstep.Add(therun);
                    }
                    return(true);
                }
            }



            therun        = rf.AddItem(runName) as Run;
            therun.Status = status;
            //therun["RN_DURATION"] = duration;
            therun.Post(); //add run
            if (File.Exists(_attachmentPath + "\\" + _attachmentName))
            {
                AttachmentFactory attachFact = therun.Attachments as AttachmentFactory;
                Attachment        attachfile;
                IExtendedStorage  extStor;
                attachfile          = attachFact.AddItem(_attachmentName) as Attachment;
                attachfile.AutoPost = true;
                extStor             = attachFact.AttachmentStorage as IExtendedStorage;
                extStor.ClientPath  = _attachmentPath;
                extStor.Save(_attachmentName, true);
                attachfile.Post();
            }

            if (File.Exists(installogPath + "\\" + installlogName))
            {
                AttachmentFactory attachFact = therun.Attachments as AttachmentFactory;
                Attachment        attachfile;
                IExtendedStorage  extStor;
                attachfile = attachFact.AddItem(installlogName) as Attachment;

                attachfile.AutoPost = true;

                extStor            = attachFact.AttachmentStorage as IExtendedStorage;
                extStor.ClientPath = installogPath;
                extStor.Save(installlogName, true);
                attachfile.Post();
            }

            therun.AutoPost = true;
            int count = 0;

            foreach (RunSteps runstep in steps)
            {
                ++count;
                Console.WriteLine("Uploading step " + count + ":" + runstep.StepName);
                runstep.Add(therun);
            }

            return(true);
        }