Beispiel #1
0
        static void Main(string[] args)
        {
            using (TCAPI tcapi = TCAPI.CreateInstance())
            {
                TCWorkspace workspace = tcapi.OpenWorkspace(
                    twsPath: @"C:\Users\estan\Desktop\trainings\TOSCA Customizations\Tosca Workspace\Training Customizations\Training Customizations.tws",
                    loginName: "Admin", loginPassword: "");
                TCProject project = workspace.GetProject();
                TCFolder  folder  = project.CreateComponentFolder();
                folder.Name = "Created folder With Script";
                folder.EnsureUniqueName();
                // workspace.Save();

                List <TCObject> search_result = project.Search(tqlString: "=>SUBPARTS:TestCase[Name==\"Test\"]");
                TestCase        copyTestCase  = (TestCase)search_result.First();
                OwnedItem       parentFolder  = copyTestCase.ParentFolder;
                // parentFolder.CheckoutTree();

                for (int i = 0; i < 10; i++)
                {
                    parentFolder.Copy(copyTestCase);
                }
                //workspace.CheckInAll("");
                workspace.Save();

                Console.WriteLine(value: "Created folder and Test Cases Copied");
            }
        }
Beispiel #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            TCAPI.CreateInstance(new Tricentis.TCAPIObjects.TCAPIConnectionInfo());

            TCWorkspace workspace = TCAPI.Instance.OpenWorkspace(txtPath.Text, txtUser.Text, txtPassword.Text);
            TCProject   project   = workspace.GetProject();

            TestCase testCase = (TestCase)project.Search($"=>SUBPARTS:TestCase[Name==\"{txtTestCase.Text}\"]").FirstOrDefault();

            if (testCase != null)
            {
                TCFolder executionListFolder = (TCFolder)project.Search("=>SUBPARTS:TCFolder[PossibleContent==\"Folder;ExecutionList\"]").First();
                if (executionListFolder.IsTaskApplicable(TCTasks.Checkout))
                {
                    executionListFolder.Checkout();
                }
                ExecutionList executionList = executionListFolder.CreateExecutionList();
                executionList.Name = txtTestCase.Text;
                executionList.CreateExecutionEntry(testCase);
                if (executionListFolder.CheckOutState.Equals(CheckOutState.CheckedOut))
                {
                    workspace.CheckInAll("Execution list created from code!");
                }
                workspace.Save();
                MessageBox.Show("Execution list created successfully");
            }
            else
            {
                MessageBox.Show("TestCase not found!");
            }
            TCAPI.Instance.CloseWorkspace();
            TCAPI.CloseInstance();
        }