简体   繁体   English

testCompile出现“无法解析的参考:”错误

[英]“Unresolved reference:” errors with testCompile

Currently, I'm getting Unresolved reference: spek and Unresolved reference: test with testCompile / testRuntime : 当前,我得到了Unresolved reference: spekUnresolved reference: test使用testCompile / testRuntime Unresolved reference: test

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"
        }
    }

However, when I switch them with compile / runtime , I can run the tests successfully! 但是,当我使用compile / runtime切换它们compile / runtime ,我可以成功运行测试!

Here's my spek test: 这是我的尖锐测试:

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)
        }
    }
})

Could someone please help me to debug this? 有人可以帮我调试一下吗?

Thank you 谢谢

I found out the cause. 我找到了原因。 My tests are inside my Source Folder . 我的测试位于“ Source Folder

To fix this, I moved my tests out, so Source Folder will not overlap with Tests Source Folder . 为了解决这个问题,我将测试移开了,因此Source Folder将不会与Tests Source Folder重叠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM