Exemple #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();
                    }
                }
            }
        }
Exemple #2
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();
            }
        }
Exemple #3
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();
            }
        }
        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);
        }