用kotlin spek和kluent运行测试
试图让科特林工作,但遇到一些问题。 我有最简单的测试:
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'