Ejemplo n.º 1
0
        public async Task <List <TestCaseResult> > UpdateTestResult(string project, string runId, TestCaseResultUpdateModel[] results)
        {
            try
            {
                connection = new VssConnection(new Uri(instance), new VssCredentials());
                TestManagementHttpClient witClient       = connection.GetClient <TestManagementHttpClient>();
                List <TestCaseResult>    testcaseresults = await witClient.UpdateTestResultsAsync(results, project, Int32.Parse(runId), null, default(CancellationToken));

                return(testcaseresults);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        private static void updateTestResultsInAzure(string testPlanId, List <Tuple <int, string> > resultList)
        {
            try{
                VssConnection connection = new VssConnection(new Uri(TFUrl), new VssBasicCredential(string.Empty, UserPAT));

                DateTime utcDate    = DateTime.UtcNow; //getting time for the run report name
                var      culture    = new CultureInfo("en-US");
                string   reportName = "Katalon Automated Tests: " + utcDate.ToString(culture) + " " + utcDate.Kind;

                int[]            excPointIds  = new int[resultList.Count];
                TestCaseResult[] excTestCases = new TestCaseResult[resultList.Count];
                for (int i = 0; i < resultList.Count; i++)
                {
                    excPointIds[i] = resultList[i].Item1;
                    string         extrapolatedOutcome = resultList[i].Item2 == "PASSED" ? "Passed" : "Failed"; //we only care if the test passed or not
                    TestCaseResult caseResult          = new TestCaseResult()
                    {
                        State = "Completed", Outcome = extrapolatedOutcome, Id = 100000 + i
                    };
                    excTestCases[i] = caseResult;
                }

                TestManagementClient = connection.GetClient <TestManagementHttpClient>();
                RunCreateModel run = new RunCreateModel(
                    name: reportName,
                    plan:  new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference(testPlanId),
                    pointIds: excPointIds
                    );

                TestRun        testrun       = TestManagementClient.CreateTestRunAsync(run, teamProjectName).Result;
                var            testResults   = TestManagementClient.UpdateTestResultsAsync(excTestCases, teamProjectName, testrun.Id).Result;
                RunUpdateModel runmodel      = new RunUpdateModel(state: "Completed");
                TestRun        testRunResult = TestManagementClient.UpdateTestRunAsync(runmodel, teamProjectName, testrun.Id, runmodel).Result;
            }
            catch (Exception e) { //catch exception with writing test case results, don't make this kill the whole process
                Console.WriteLine(e.Message.ToString());
                Console.WriteLine(e.StackTrace.ToString());
            }
        }