I have been trying to solve how to get junit (test results) into my projects merge requests. I setup a special helloworld project to see if I could get it working. Originally I built a very simple object and testing its method with googletest then recording the results ("./unit-test --gtest_output=json" or “./unit-test --gtest_output=xml”) and passing those into artifacts:reports:junit. The results always seem to be the same on the merge page it recognizes that I want unit tests reported but I always get the error “Test summary failed loading results”.
So I canned all the results so I could play with the format a little better. I have a project containing the following files at the root.
FILE: test_detail.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" disabled="0" errors="0" timestamp="2018-09-02T01:35:56" time="0.001" name="AllTests">
<testsuite name="HelloMarsTest" tests="1" failures="1" disabled="0" errors="0" time="0">
<testcase name="Basic" status="run" time="0" classname="HelloMarsTest">
<failure message="gtest_main.C:8
Expected equality of these values:
 "marss"
 mars.getName().c_str()
 Which is: "mars"" type=""><![CDATA[gtest_main.C:8
Expected equality of these values:
"marss"
mars.getName().c_str()
Which is: "mars"]]></failure>
</testcase>
</testsuite>
</testsuites>
FILE: test_detail.json
{
"tests": 1,
"failures": 1,
"disabled": 0,
"errors": 0,
"timestamp": "2018-09-02T01:51:36Z",
"time": "0.001s",
"name": "AllTests",
"testsuites": [
{
"name": "HelloMarsTest",
"tests": 1,
"failures": 1,
"disabled": 0,
"errors": 0,
"time": "0s",
"testsuite": [
{
"name": "Basic",
"status": "RUN",
"time": "0s",
"classname": "HelloMarsTest",
"failures": [
{
"failure": "gtest_main.C:8\nExpected equality of these values:\n \"marss\"\n mars.getName().c_str()\n Which is: \"mars\"",
"type": ""
}
]
}
]
}
]
}
FILE: .gitlab-ci.yml
image: ubuntu:18.04
stages:
- test
test:
stage: test
tags:
- docker
script:
- echo hi
artifacts:
expire_in: 1 hour
reports:
junit: test_detail.xml
I have attempted this with both test_detail.xml and test_detail.json in the artifacts:reports:junit section. Any suggestions?
Thanks!