https://kotlinlang.org logo
#mockk
Title
# mockk
k

Klitos Kyriacou

09/12/2021, 9:36 PM
When I use io.mock.every like this:
Copy code
every { mockObj.methodXYZ() } returns "..."
IntelliJ IDEA occasionally puts red lines underneath
every
and on hovering it says "Cannot access class 'io.mockk.MockKStubScope'. Check your module classpath for missing or conflicting dependencies". And it shows "unresolved reference: returns" obviously because that's a method of MockKStubScope which it isn't accessing. This is only a problem in the editor. If I do a "Build" or "Rebuild", it builds successfully (but the red line under
every
still remains). Sometimes, when I invalidate caches and restart, the problem goes away, but not always. My dependency is:
Copy code
<dependency>
    <groupId>io.mockk</groupId>
    <artifactId>mockk</artifactId>
    <version>1.12.0</version>
    <scope>test</scope>
</dependency>
The class MockKStubScope is defined in mockk-dsl-jvm-1.12.0.jar, which is a transitive dependency. Is this a known issue, or am I using mockk incorrectly?
m

Mattia Tommasone

09/13/2021, 7:24 AM
you’re using mockk correctly and it looks like an intellij issue rather than an issue with mockk 😞
🙏 1
l

LeoColman

09/13/2021, 4:05 PM
Yep. This happens to me from time to time for random libraries
k

Klitos Kyriacou

09/13/2021, 5:07 PM
https://youtrack.jetbrains.com/issue/KTIJ-19504 says it's a bug in the Kotlin plugin version 1.5.30 that's fixed in a forthcoming release. Workaround is to downgrade the plugin.
49 Views