admin管理员组

文章数量:1122832

I am using the api url POST /{organization}/{project}/_apis/test/Runs/{runId}/results?api-version=7.1 which is mentioned on this page .1&tabs=HTTP#testsubresult to create a test case result

i am creating the result using the TestCaseResult[] and successfully being able to see the result on azure devops

the only problem is that i am not able to get the details part filled in any way. I have the stack trace filled, the error message filled.. but the details should show the steps executed which would be shown in case i am creating a bug from this

This is the code i am using:

listOf(
    TestCaseResultRequestBody(
                    automatedTestName = testCaseResult.title,
                    testRun = ShallowReferenceString(testRunId),
                    durationInMs = testCaseResult.testCaseResult.duration.toMillis(),
                    state = "Completed",
                    outcome = testCaseResult.status.lowercase().capitalize(),
                    testCase = ShallowReference(testCaseResult.workItemMeta.Id.toInt(), name = testCaseResult.annotatedTitle),
                    testPlan = ShallowReferenceString(testPlanId),
                    testPoint = ShallowReferenceString(testPointId),
                    testCaseRevision = testCaseResult.workItemMeta.Revision.toInt(),
                    testCaseTitle = testCaseResult.annotatedTitle,
                    comment = "test",
                    stackTrace =  testCaseResult.stackTrace,
                    errorMessage = if (testCaseResult.failureMessage.isEmpty()) {
                        null
                    } else {
                        val failure = testCaseResult.steps.map {
                            "${it.status.name}: "+it.stepDescription
                        }.joinToString("\n")
                        failure
                    }
                )
            }
    )
            val jsonPayload =  JsonConfig.json.encodeToString(ListSerializer(TestCaseResultRequestBody.serializer()), testCaseResults)
    
            val client = HttpClient.newHttpClient()
            val request = httpRequestBuilder("$AZURE_BASE_URL/test/runs/$testRunId/results?api-version=7.1")

                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build()
    
            val response = client.send(request, HttpResponse.BodyHandlers.ofString())

本文标签: Create Test Case Result using Azure DevOps APIStack Overflow