使用 kotlin spek 和 kluent 运行测试



试图让 spek 使用 kotlin 但遇到了一些问题。我有最简单的测试:

object TestSpec : Spek({
describe("A greeter") {
it("should fail") {
"hello" shouldEqual "somethingelse"
}
}
})

而且它不起作用。我尝试了以下变体:

object TestSpec : Spek({
describe("A greeter") {
it("should fail") {
"hello" shouldEqual "somethingelse"
}
}
})

这个测试是绿色的,显然不应该是。

object TestSpec : Spek({
describe("A greeter") {
on("something") {
it("should fail") {
"hello" shouldEqual "hellosdf"
}
}
}
})

此测试甚至不运行。当我执行它时,我只是得到

测试框架意外退出

以下变体相同:

object TestSpec : Spek({
given("A greeter") {
on("something") {
it("should fail") {
"hello" shouldEqual "hellosdf"
}
}
} 
})

我的 maven 依赖项:

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.spek</groupId>
<artifactId>spek-api</artifactId>
<version>1.1.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jetbrains.spek</groupId>
<artifactId>spek-junit-platform-engine</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.amshove.kluent</groupId>
<artifactId>kluent</artifactId>
<version>1.24</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.0.0-M5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M5</version>
<scope>test</scope>
</dependency>

如果我现在运行测试,我只会得到Test framework quit unexpectedly,没有任何其他信息。

还将代码放在github上,如果有人想检查链接,可能会更容易

您似乎缺少依赖项(http://spekframework.org/docs/latest/#setting-up-legacy(。检查您是否具有以下各项:

org.jetbrains.spek:spek-api:1.1.2
org.jetbrains.spek:spek-junit-platform-engine:1.1.2
org.junit.platform:junit-platform-runner:1.0.0-M4
// this one too if you use IntelliJ
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.0.0-M4'

最新更新