Kotest: NoSuchFileException when using kotest-extensions-junitxml with Gradle

Created on 21 Jul 2020  Â·  3Comments  Â·  Source: kotest/kotest

I am trying to use kotest-extensions-junitxml to get a flattened JUnit report in a Gradle project (related to #999), but every test class fails with a NoSuchFileException, because it is looking for the XML file in the target directory, instead of build/test-results/test/ where Gradle puts the file.

This behavior is currently hardcoded: https://github.com/kotest/kotest/blob/056c8b58cbfe601039d5a671abe0bd381b6e19d3/kotest-extensions/kotest-extensions-junitxml/src/jvmMain/kotlin/io/kotest/extensions/junitxml/JunitXmlListener.kt#L90

I have only added the dependency to io.kotest:kotest-extensions-junitxml:4.1.2 [1], is there anything else I need to do to make it work?

You can see the error here: https://travis-ci.com/github/oss-review-toolkit/ort/builds/176483622#L1023

[1] https://github.com/oss-review-toolkit/ort/pull/2872/files

bug

All 3 comments

Will be fixed for 4.2.0

On Tue, 21 Jul 2020, 08:50 Martin Nonnenmacher, notifications@github.com
wrote:

I am trying to use kotest-extensions-junitxml to get a flattened JUnit
report in a Gradle project, but every test class fails with a
NoSuchFileException, because it is looking for the XML file in the target
directory, instead of the build/test-results/test/ where Gradle puts the
file.

This behavior is currently hardcoded:
https://github.com/kotest/kotest/blob/056c8b58cbfe601039d5a671abe0bd381b6e19d3/kotest-extensions/kotest-extensions-junitxml/src/jvmMain/kotlin/io/kotest/extensions/junitxml/JunitXmlListener.kt#L90

I have only added the dependency to
io.kotest:kotest-extensions-junitxml:4.1.2 [1], is there anything else I
need to do to make it work?

You can see the error here:
https://travis-ci.com/github/oss-review-toolkit/ort/builds/176483622#L1023

[1] https://github.com/oss-review-toolkit/ort/pull/2872/files

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/kotest/kotest/issues/1581, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAFVSGRS4SNF3HKQLVYPBLLR4WMKRANCNFSM4PDTZQ4Q
.

Fixed in master. You will need to specify the build dir when you setup the tests in gradle like this: https://github.com/kotest/kotest/blob/master/kotest-tests/kotest-tests-junitxml/build.gradle.kts#L47

Additionally, you will need to add the JUnitXmlReporter as a listener manually, rather than using AutoScan, similar to this: https://github.com/kotest/kotest/blob/master/kotest-tests/kotest-tests-junitxml/src/jvmTest/kotlin/com/sksamuel/kotest/ProjectConfig.kt

Thanks @sksamuel, that's great news. I have tried 4.2.0-RC1 and it works!

Was this page helpful?
0 / 5 - 0 ratings