Beispiel #1
0
 /// <summary>Updates the specified TestSet with the given status.</summary>
 /// <param name="TestSetId">The TestSet to update.</param>
 /// <param name="ProjectId">The ProjectId that contains the TestSet.</param>
 /// <param name="Status">The status to update the TestSet to.</param>
 public void UpdateTestSetStatus(int TestSetId, int ProjectId, PendingSet.PendingSetRunStatusEnum Status)
 {
     try
     {
         RemoteTestSet testSet = this.GetTestSetById(ProjectId, TestSetId);
         testSet.TestSetStatusId = (int)Status;
         this._client.TestSet_Update(testSet);
     }
     catch
     { }
 }
Beispiel #2
0
        /// <summary>Gets automated test runs for the specified TexstSetLaunch class.</summary>
        /// <param name="testSetLaunch">The specified data from a TST file.</param>
        /// <returns>PendingSet</returns>
        public PendingSet GetSpecifiedTests(TestSetLaunch testSetLaunch)
        {
            PendingSet retSet = null;

            //The testset.
            RemoteTestSet testSet = null;

            //Get the test set, first.
            if (testSetLaunch.ProjectId == null)
            {
                //Have to find the projectId.
                RemoteProject[] remoteProjects = this._client.Project_Retrieve();
                for (int i = 0; i < remoteProjects.Length && testSet == null; i++)
                {
                    //Connect to the project.
                    if (this._client.Connection_ConnectToProject(remoteProjects[i].ProjectId.Value))
                    {
                        testSet = this._client.TestSet_RetrieveById(testSetLaunch.TestSetId);
                    }
                }
            }
            else
            {
                if (this._client.Connection_ConnectToProject(testSetLaunch.ProjectId.Value))
                {
                    testSet = this._client.TestSet_RetrieveById(testSetLaunch.TestSetId);
                }
            }

            //Now get the newly created test runs..
            if (testSet != null)
            {
                //Get the tests for the testset.
                List <RemoteAutomatedTestRun> testRuns = new List <RemoteAutomatedTestRun>();
                testRuns.AddRange(this._client.TestRun_CreateForAutomatedTestSet(testSetLaunch.TestSetId, this.HostName));

                //Create and add the pending set.
                retSet = new PendingSet(testSet.Name);
                foreach (RemoteAutomatedTestRun testRun in testRuns)
                {
                    testRun.ScheduledDate = DateTime.Now;
                    retSet.AddPendingTestRun(testRun);
                }
            }

            return(retSet);
        }
        /// <summary>
        /// Imports the test plans
        /// </summary>
        /// <param name="streamWriter"></param>
        /// <param name="spiraClient"></param>
        /// <param name="testRailApi"></param>
        private void ImportTestPlans(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, APIClient testRailApi)
        {
            //Get the test cases from the TestRail API
            JArray testPlans = (JArray)testRailApi.SendGet("get_plans/" + this.testRailProjectId);

            if (testPlans != null)
            {
                foreach (JObject testPlan in testPlans)
                {
                    //Extract the test rail data
                    int  testRailId  = testPlan["id"].Value <int>();
                    bool isCompleted = testPlan["is_completed"].Value <bool>();

                    //Create the new SpiraTest test set
                    RemoteTestSet remoteTestSet = new RemoteTestSet();
                    remoteTestSet.Name            = testPlan["name"].Value <string>();
                    remoteTestSet.Description     = testPlan["description"].Value <string>();
                    remoteTestSet.TestSetStatusId = (isCompleted) ? /* Completed */ 3 : /* Not Started */ 1;
                    remoteTestSet.TestRunTypeId   = 1; /* Manual */
                    int?createdById = testPlan["created_by"].Value <int?>();
                    if (createdById.HasValue && this.usersMapping.ContainsKey(createdById.Value))
                    {
                        remoteTestSet.CreatorId = this.usersMapping[createdById.Value];
                    }

                    int newTestSetId = spiraClient.TestSet_Create(remoteTestSet).TestSetId.Value;
                    streamWriter.WriteLine("Added test plan: " + testRailId);

                    //Add to the mapping dictionary
                    if (!this.testSetMapping.ContainsKey(testRailId))
                    {
                        this.testSetMapping.Add(testRailId, newTestSetId);
                    }

                    //Test Rail doesn't map test cases to test plans, so we don't map them
                }
            }
        }
Beispiel #4
0
        /// <summary>Retrieves the upcoming tests that are scheduled up to the toDate.</summary>
        /// <param name="toDate">The date for the cutoff of upcoming tests.</param>
        /// <returns>A list of upcoming test runs.</returns>
        public List <PendingSet> GetUpcomingTests(DateTime toDate)
        {
            DateRange dteRange = new DateRange()
            {
                StartDate = DateTime.Now, EndDate = toDate
            };

            //Create a new dictionary..
            Dictionary <int, PendingSet> setRuns = new Dictionary <int, PendingSet>();

            //Get a list of projects and loop through each one.
            RemoteProject[] remoteProjects = this._client.Project_Retrieve();
            foreach (RemoteProject remoteProject in remoteProjects)
            {
                try
                {
                    if (this._client.Connection_ConnectToProject(remoteProject.ProjectId.Value))
                    {
                        RemoteAutomatedTestRun[] testRuns = this._client.TestRun_CreateForAutomationHost(this.HostName, dteRange);
                        //Loop through each TestRun..
                        foreach (RemoteAutomatedTestRun testRun in testRuns)
                        {
                            //If the test set already exists..
                            if (setRuns.ContainsKey(testRun.TestSetId.Value))
                            {
                                //Add it.
                                setRuns[testRun.TestSetId.Value].AddPendingTestRun(testRun);
                            }
                            else
                            {
                                //Create a new one and add it.
                                //Get the test set name..
                                string strTestSetName = "Test Set #" + testRun.TestSetId.Value.ToString();
                                try
                                {
                                    RemoteTestSet specifiedTestSet = this._client.TestSet_RetrieveById(testRun.TestSetId.Value);
                                    strTestSetName = specifiedTestSet.Name;
                                }
                                catch { }

                                //Create and add the pending set.
                                PendingSet newSet = new PendingSet(strTestSetName, testRun);
                                newSet.OverDue = (testRun.ScheduledDate < DateTime.Now);
                                setRuns.Add(testRun.TestSetId.Value, newSet);
                            }
                        }
                    }
                    else
                    {
                        Logger.LogMessage("Error retrieving upcoming tests. Could not connect to project #" + remoteProject.ProjectId, System.Diagnostics.EventLogEntryType.Warning);
                    }
                }
                catch
                {
                    //No reason to log an error here.
                }
            }

            //Copy over the pending sets into a new date-ordered list.
            List <PendingSet> retDict = new List <PendingSet>();

            foreach (KeyValuePair <int, PendingSet> pendingSet in setRuns)
            {
                retDict.Add(pendingSet.Value);
            }

            return(retDict);
        }