https://kotlinlang.org logo
#kotest
Title
# kotest
m

Mervyn McCreight

10/20/2021, 5:49 PM
Hi folks 🙂 I stumbled upon an issue with the
JUnitXmlReporter
in one of my projects. I set it up according to the documentation, but the final XML files still only contain the leaf name of the tests for nested tests. What I have seen while debugging that the reporter itself is working correctly and directly after doing the file operations in the reporter the XML files are correct. But something happens afterwards overwriting the XML files from the
JUnitXmlReporter
😞 Anyone got an idea or can see the same behaviour? Im using version
4.6.3
of KoTest.
s

sam

10/20/2021, 5:51 PM
You can pass the parameter useTestPathAsName=true to the reporter to get the full test path name
m

Mervyn McCreight

10/21/2021, 8:01 AM
Yeah, that is what I did. The reporter does create the file as expected, but something overwrites it afterwards 🤔 at least it seems like that
s

sam

10/21/2021, 2:18 PM
I wonder if junit platform or gradle overwrites them. Do they generate if you turn off the kotest one
m

Mervyn McCreight

10/21/2021, 2:18 PM
How do I turn it off for KoTest? 🤔
s

sam

10/21/2021, 2:20 PM
Delete where ever you added the reporter
m

Mervyn McCreight

10/21/2021, 2:21 PM
Ok, will check it in a minute.
I have a class extending
AbstractProjectConfig
where I added the reporter to the listeners. When I remove the reporter from the list of listeners, I see the same report getting generated.
But checking if gradle generates the report is a good hint. I will take a look in this direction and see where I end up 🙂
You were right with your guess. It was gradle generating the reports. I had do add:
Copy code
tasks.withType<Test> {
    useJUnitPlatform()
    // this reports block I needed to add
    reports {
        junitXml.required.set(false)
    }
    systemProperty("gradle.build.dir", project.buildDir)
}
To the
build.gradle.kts
and now the report of the
JUnitXmlReporter
does not get overwritten anymore. Thanks for your help!
s

sam

10/21/2021, 2:30 PM
Cool you're welcome
m

Mervyn McCreight

10/21/2021, 2:30 PM
Maybe this is worth mentioning in the documentation of the
JUnitXmlReporter
on the page of KoTest? 🤔
s

sam

10/21/2021, 2:30 PM
Yes definitely. Wanna PR ?
m

Mervyn McCreight

10/21/2021, 2:31 PM
I'm happy to serve a PR, will look at it later in the day 🙂
s

sam

10/21/2021, 2:31 PM
Thanks
🙌 1
m

Mervyn McCreight

10/21/2021, 5:20 PM
s

sam

10/21/2021, 5:24 PM
thanks merged
m

Mervyn McCreight

10/21/2021, 5:25 PM
🎉 my first "contribution" to KoTest 😄
s

sam

10/21/2021, 5:25 PM
first of many 😉
4 Views