"Unresolved reference:" testCompile 错误

"Unresolved reference:" errors with testCompile

目前,我得到 Unresolved reference: spekUnresolved reference: test 以及 testCompile / testRuntime:

project(":core") {
        apply plugin: "kotlin"

        dependencies {
            // ... other dependencies
            testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
            testCompile "org.jetbrains.spek:spek-api:$spekVersion"
            testRuntime "org.jetbrains.spek:spek-junit-platform-engine:$spekVersion"
            testCompile "com.nhaarman:mockito-kotlin:$mockitoVersion"
            testCompile "com.natpryce:hamkrest:$hamkrestVersion"
        }
    }

但是,当我用 compile / runtime 切换它们时,我可以 运行 测试成功!

这是我的语音测试:

package com.mysampleapp

import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.it
import kotlin.test.assertEquals

class DummySpec : Spek({
    describe("a dummy") {
        it("contains a number") {
            val dummy = Dummy(1)

            assertEquals(1, dummy.number)
        }
    }
})

有人可以帮我调试一下吗?

谢谢

我找到原因了。我的测试在我的 Source Folder.

为了解决这个问题,我移出了我的测试,所以 Source Folder 不会与 Tests Source Folder 重叠。