Currently I'm trying out multi module with kotlin and gradle. Also trying to implement gitlab cicd p...
m
Currently I'm trying out multi module with kotlin and gradle. Also trying to implement gitlab cicd pipeline. But how can I have al the test results of the multiple modules show in gitlab? I tried a plugin (test report aggregation) but that wasn't the right plugin because it doesn't aggregate the xml files but it does the html ones. Does anyone have an idea how I can show all my test result in gitlab after a test run?
m
The newest version of Gradle adds this feature. Is that what you used?
m
Yes, but apparently it doesn't support the xml files
m
It being the plugin or Kotlin? If Kotlin you may want to check this out: https://youtrack.jetbrains.com/issue/KT-32608
m
the plugin because I have xml's from kotlin
m
Does the plugin really not support XML aggregation? I had this on my list of things to add to my project too...
m
I'm not really sure but I haven't found out. I'm a noob when it comes to gradle
m
Anyhow in GitLab CI you can get it to report the results on the MR by doing something like this.
Copy code
artifacts:
    when: always
    paths:
      - '*/build/reports/'
      - '*/build/test-results/'
    reports:
      junit:
        - '*/build/test-results/*/TEST-*.xml'
Note that the leading
*
is only one folder deep.
👀 1
The release notes in Gradle do say,
This release adds the new
test-report-aggregation
plugin to make it easy to aggregate test results from multiple projects into a single HTML report.
Emphasis mine 😢
😢 1
Let me check the API doc to see if it's an accidental omission or for real
🤞 1
It looks like the
TestReportAggregation
task is a thin wrapper around
TestReport
, which "Generates an HTML test report from the results of one or more
Test
tasks." https://docs.gradle.org/7.4.2/javadoc/org/gradle/api/tasks/testing/TestReport.html Now that I'm thinking about it, I was most interested in the HTML report and coverage reports -- why do you want one XML file? When I run my tests, I get one test xml file per test class. Is a single XML file a problem you really need to solve for?
m
I though it might be needed to have all the xml's in one folder, currently testing the code you sent. Hopefully it works, Thank you for the help 😊
👍 1
It works, Thank you. Sorry for bringing you on the wrong path.
v
Having all in one folder would actually be trivial using a copy task and the aggregation plugin. The plugin does not only register a task that generates the html report, but also defines a configuration that resolves to the various result files, so you could easily copy that to a destination folder. But as you found out already, that is usually not necessary.