httpyac
httpyac copied to clipboard
Sometimes junit xml output fails to produce name in testsuite
Problem: While trying to run a .http file and return a output as Junit XML file I'm getting an ill formed. One of the Test Suite does not get name. This causes the my parser for Junit test to start failing
The XML is
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="httpyac" tests="7" errors="0" disabled="0" failures="1" time="0.546">
<testsuite name="GET /int-process-api-{{ENVIRONMENT}}/v1/ping (line: 20)" tests="2" errors="0" failures="0" skipped="0" package="tests/apis/int-process-api/int-process-v1.http" time="0.025">
<properties>
<property name="line" value="18"/>
<property name="timestamp" value="2024-09-09T05:52:59.318Z"/>
<property name="file" value="tests/apis/int-process-api/int-process-v1.http"/>
</properties>
<testcase name="status == 200" classname="GET /int-process-api-{{ENVIRONMENT}}/v1/ping (line: 20)" time="0.013" assertions="1"/>
<testcase name="lastActiveAt exists" classname="GET /int-process-api-{{ENVIRONMENT}}/v1/ping (line: 20)" time="0.013" assertions="1"/>
</testsuite>
<testsuite tests="1" errors="0" failures="0" skipped="0" package="tests/apis/int-process-api/int-process-v1.http" time="0.187">
<properties>
<property name="line" value="40"/>
<property name="timestamp" value="2024-09-09T05:52:59.382Z"/>
<property name="file" value="tests/apis/int-process-api/int-process-v1.http"/>
</properties>
<testcase name="status == 200" time="0.187" assertions="1"/>
</testsuite>
</testsuites>
HTTP Test
###
@title Ping the API
GET /int-process-api-{{ENVIRONMENT}}/v1/ping HTTP/1.1
Authorization: openid client_credentials local
X-Correlation-ID: {{$guid}}
?? status == 200
?? body lastActiveAt exists
###
@title Validate API Test 1
GET /int-process-api-{{ENVIRONMENT}}/v1/licence HTTP/1.1
Authorization: openid client_credentials local
X-Correlation-ID: {{$guid}}
?? status == 200
Possible issue: I was looking at the Json generated for this test case and it seems that we are not getting name and title for this.
"name": "",
"line": 28,
"title": "",
"testResults": [
{
"message": "status == 200",
"result": true
}
These values then are not defaulted in the junitUtils.ts file causing the XML to ignore them. Not sure why it does not show in this object for Ping response I can see this populating
"name": "GET /int-process-api-electrical-contractor-{{ENVIRONMENT}}/v1/ping (line: 20)",
"line": 18,
"testResults": [
{
"message": "status == 200",
"result": true
},
{
"message": "lastActiveAt exists",
"result": true
}