lupuuss / Mokkery

The mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.
https://mokkery.dev
Apache License 2.0
201 stars 8 forks source link

Shorthand for adding mokkery-coroutines does not work #32

Closed dalewking closed 2 months ago

dalewking commented 3 months ago

The docs say you can do this:

import dev.mokkery.gradle.mokkery

dependencies {
    implementation(mokkery("coroutines")) // defaults to the current Mokkery version
}

but i get:

Type mismatch: inferred type is String but Action was expected

lupuuss commented 3 months ago

Could you give me a reproducer? It works in my test project.

dalewking commented 3 months ago

To be more specific it doesn't work for Kotlin Multiplatform projects as in:

kotlin {
    sourceSets {
        commonTest.dependencies {
            implementation(mokkery("coroutines"))
        }
    )
}

The reason is that the short hand syntax works on DependencyHandler, but those dependency blocks are actually of type KotlinDependencyHandler and do not extend DependencyHandler

lupuuss commented 3 months ago

I understand. I will try to add an overload in the next release.