I'm writing a unit test for my convention plugin a...
# gradle
d
I'm writing a unit test for my convention plugin and I want to read a file in
build-logic/convention/src/test/resources/
with
getResource
, like I would do normally in my app, but it seems it's trying to read it from
build-logic/convention/build/classes/kotlin/test/
. My test class is there, but I don't see any resource there. What I'm missing?
v
Can you provide an MCVE? It should work just fine. It would look in
build-logic/convention/build/resources/test/
where it is put by
processTestResources
.
d
Weird. I copied my
build-logic
directory to a new project and it's working there. In my original project
processTestResources
isn't even running. Will investigate.
👌 1
Found the culprit. It was this workaround that I had to use when I didn't have tests in my plugins:
Copy code
// workaround for <https://github.com/gradle/gradle/issues/28407>, <https://issuetracker.google.com/issues/331902968>
gradle.startParameter.excludedTaskNames.addAll(listOf(":build-logic:convention:testClasses"))
After removing it, it works. Additionally, when I apply my plugin and run the plugin tests, I get "Test events were not received" in Android Studio. Only when I don't apply the plugin I can see the tests execution and the text printed with
println
(so maybe stdout is being "eaten" somehow?)
v
Only when I don't apply the plugin I can see the tests execution and the text printed with
println
(so maybe stdout is being "eaten" somehow?)
Again, an MCVE might be necessary to show what you mean. At least to me it is not really clear what situation and problem you have.
Besides that it is most probably off-topic here, as it does not sound like in any way Kotlin-related even when using Kotlin as implementation language. 😉