I have this extension:
src/main/kotlin/com/myproject/api/extensions.kt
fun String.asJson() : JsonObject {
return JsonObject.readFrom(this)
}
When I run my application, it works fine. But, when I run a test case that uses that extension function, it crashes:
java.lang.NoSuchMethodError: com.myproject.api.ExtensionsKt.asJson(Ljava/lang/String;)Lcom/eclipsesource/json/JsonObject;
What am I missing?
After hours, I finally found the error. I already had a extensions.kt
file in the same package but in test directory! src/test/kotlin/com/myproject/api/extensions.kt
. I changed the name to testExtensions.kt
and everything is working now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With