How-to
Send a JUnit XML report
Send a JUnit XML report
After your tests finish, the pipeline posts one JUnit XML file. ComplexQA stores a run, the suites, the executions, and a test card that stays between runs.
The same import is available by hand: in the project open External tests → Tests and press Load XML. The dialog has the same optional Name field as the request field name. A pipeline uses a key and the request below, not that button.
Prerequisites
- You can open the project and you are an accepted member of its team.
- You can issue an API key for that team.
- The test tool can write a JUnit XML file. The root is
testsuitesor onetestsuite.
1. Issue a key
A person issues the key in the browser. The pipeline cannot create a key.
- Sign in as a member of the team that should receive the report.
- Open the profile, tab API keys. From the project, AI → API keys opens the same tab.
- Press Create key.
- Fill the dialog:
- Name - how you will recognize the key, for example
GitLab build; - Team - the team of the project;
- Lifetime, days - an integer from 1 to 90. A key without a lifetime is not issued.
- Name - how you will recognize the key, for example
- Press Create key.
- Copy the secret at once. ComplexQA does not show it again. The list keeps the name, the team, the lifetime, and the last characters of the secret.
The secret starts with cqa_web_api_. The dialog also shows the header to send:
Authorization: Bearer cqa_web_api_…The key acts as you inside the chosen team. The lifetime is at most 90 days. X-Team-Slug is optional for this key and cannot switch the team. This secret cannot issue or revoke keys.
Do not put the secret in the repository, in the pipeline file, or in a log. Store it in a secret variable. The examples below call it COMPLEXQA_WEB_API_KEY.
To revoke: on the same tab press Revoke. Requests with that secret stop at once.
2. Take the host and the project number
The project number is project_id in the address of any page of that project. Example:
https://team.example/web/en/junit_xml_test/listing?project_id=50Here the project number is 50. Store it as COMPLEXQA_PROJECT_ID.
The import address is the same host, path /web_api/junit_xml_test/import:
https://team.example/web_api/junit_xml_test/importStore the host without the path as COMPLEXQA_BASE_URL, for example https://team.example. There is no separate host only for this import.
The project must belong to the key's team. Another team's project is rejected.
3. Write the JUnit XML file
The pipeline runs the tests as usual and asks the tool to write JUnit XML. The examples use the file name junit.xml.
PHPUnit:
vendor/bin/phpunit --log-junit junit.xmlpytest:
pytest --junitxml=junit.xmlThe root is testsuites or one testsuite. Another root, and XML that cannot be parsed, is not stored. A testcase without name is skipped. The other rows of the file are stored.
Send the file after the tests with an "always" condition, or a failed suite never arrives.
4. Post the file
POST /web_api/junit_xml_test/import.
The body is a form, not JSON:
| Field | Meaning |
|---|---|
project_id | project number from the address |
file | the JUnit XML file |
name | optional run name, at most 1000 characters |
Run name
The run title is not taken from the file. The tool label vitest tests and a PHPUnit suite name stay suite names. They are not the run title.
name sets the title. A useful mask is repository, application version, date. Example: test_site 1.41.1 2026-11-29.
If the field is omitted or only spaces, the list shows the reception date and time as Y-m-d H:i, for example 2026-11-29 10:53. A file that is already stored is not rewritten. The new name and the new totals appear only on the next file.
A name longer than 1000 characters is rejected. api_error.message is Name is too long.
Run totals
A Vitest root usually already has tests, failures, errors, and time. A PHPUnit root (testsuites) does not, so without a fill-in the run totals are empty.
When one of those four values is missing on the root, the import counts it from executions that have a name:
| Run field | Source when the root value is missing |
|---|---|
tests | how many such rows |
failures | rows with status FAILED |
errors | rows with status ERROR |
time_seconds | sum of time on those rows; if none has a time, the field stays empty |
A value the root already sent is not recalculated. Zero stays zero.
Do not add up tests on nested suites. In PHPUnit the parent already includes the child suites, and the sum would count the tests twice. Skipped executions are not a separate column on the run. Status SKIPPED is on the rows and on the charts of the run page.
Send Authorization: Bearer and the secret from step 1. Do not set Content-Type yourself: the client sets it with the form boundary. A session cookie and a CSRF token are not required.
Check from a machine that has the file:
curl --silent --show-error \
--output response.json \
--write-out "%{http_code}" \
--request POST \
--header "Authorization: Bearer ${COMPLEXQA_WEB_API_KEY}" \
--form "project_id=${COMPLEXQA_PROJECT_ID}" \
--form "name=test_site 1.41.1 2026-11-29" \
--form "file=@junit.xml" \
"${COMPLEXQA_BASE_URL}/web_api/junit_xml_test/import"The same request from PowerShell. Use curl.exe: curl without .exe starts another command. Put your application host in COMPLEXQA_BASE_URL.
curl.exe --silent --show-error `
--output $env:TEMP\junit-response.json `
--write-out "%{http_code}" `
--request POST `
--header "Authorization: Bearer $env:COMPLEXQA_WEB_API_KEY" `
--form "project_id=$env:COMPLEXQA_PROJECT_ID" `
--form "name=test_site 1.41.1 2026-11-29" `
--form "file=@junit.xml" `
"$env:COMPLEXQA_BASE_URL/web_api/junit_xml_test/import"
Get-Content $env:TEMP\junit-response.jsonSuccess is HTTP 200 and "api_code":200 in the body. api_result has three fields:
| Field | Meaning |
|---|---|
junit_xml_run_id | number of the new run |
suite_count | how many suites were stored |
testcase_count | how many executions were stored |
Example:
{
"api_code": 200,
"api_result": {
"junit_xml_run_id": 1,
"suite_count": 28,
"testcase_count": 94
}
}A rejected file still comes with HTTP 200 and "api_code":-422. Read api_error.message, not only the process exit code of curl.
api_error.message | When |
|---|---|
Choose a JUnit XML file. | no project_id or no file |
Project was not found. | the project is not in the key's team |
JUnit XML is empty. | the file is empty |
JUnit XML was not accepted. | this is not XML, or the root is not testsuites or testsuite |
Name is too long. | name is longer than 1000 characters |
HTTP 401 or 403 means the secret was not accepted: revoked, expired, truncated, or not a cqa_web_api_ key.
Sending the same file again creates a new run and new executions. The test card is not duplicated. In one project the pair classname and name stays one card. The latest class, file, and line are updated on it.
5. Put the post in the pipeline
The secret stays in a secret variable. The project number and the host can be ordinary variables.
GitHub Actions, after the test step:
- name: Send JUnit XML
if: always()
env:
COMPLEXQA_WEB_API_KEY: ${{ secrets.COMPLEXQA_WEB_API_KEY }}
COMPLEXQA_PROJECT_ID: ${{ vars.COMPLEXQA_PROJECT_ID }}
COMPLEXQA_BASE_URL: ${{ vars.COMPLEXQA_BASE_URL }}
run: |
http_code=$(curl --silent --show-error \
--output response.json \
--write-out "%{http_code}" \
--request POST \
--header "Authorization: Bearer ${COMPLEXQA_WEB_API_KEY}" \
--form "project_id=${COMPLEXQA_PROJECT_ID}" \
--form "name=test_site 1.41.1 2026-11-29" \
--form "file=@junit.xml" \
"${COMPLEXQA_BASE_URL}/web_api/junit_xml_test/import")
cat response.json
if [ "$http_code" != "200" ] || ! grep -q '"api_code":200' response.json; then
exit 1
fiGitLab CI, a separate job after the tests. Set the variables in the project settings: mask COMPLEXQA_WEB_API_KEY, and set COMPLEXQA_PROJECT_ID and COMPLEXQA_BASE_URL.
send_junit_xml:
stage: report
rules:
- when: always
script:
- |
http_code=$(curl --silent --show-error \
--output response.json \
--write-out "%{http_code}" \
--request POST \
--header "Authorization: Bearer ${COMPLEXQA_WEB_API_KEY}" \
--form "project_id=${COMPLEXQA_PROJECT_ID}" \
--form "name=test_site 1.41.1 2026-11-29" \
--form "file=@junit.xml" \
"${COMPLEXQA_BASE_URL}/web_api/junit_xml_test/import")
cat response.json
if [ "$http_code" != "200" ] || ! grep -q '"api_code":200' response.json; then
exit 1
fiThe job must be able to read junit.xml. If the tests and the post are different jobs, pass the file as a pipeline artifact.
6. Check in ComplexQA
Open the project, group External tests.
- Runs - a new row. Its number is
junit_xml_run_id. - The run page - two passage charts, Details, and Results with the file rows.
- Suites - the suites from this file.
- Tests - the cards. The same file again does not add a second card with the same
classnameandname. - Executions - one row per stored
testcase.
On API keys, Last used is filled for that key.
What this call does not do
- It does not start your pipeline from ComplexQA.
- It does not read the repository and does not store the test code.
- It does not create a manual test case and does not link an execution to an existing case.
- It does not write platform autotests (
autotest_case,autotest_run,autotest_result) or a manual run (test_run,test_run_result).
Did this page help?