2017-07-11 37 views
1

試圖用kotlin獲得spek,但遇到一些問題。我有最簡單的測試:用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上,如果有人要檢查link

+0

請運行gradle,選擇'./gradlew build --info --stacktrace'並將其輸出。 – guenhter

+0

我很傷心地使用maven。更新以顯示我知道的更多 –

回答

1

看來你有一個丟失的依賴(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' 
+0

很確定我有這些,請參閱我的maven文件 –

+0

請將'junit-platform-runner'和'junit-jupiter-api'的版本從'...- M5'降到'。 ..- M4'(顯示在此答案的片段中)。這將解決您的問題。原因是在不兼容的里程碑中發生了一些重大變化。我相信,這將在未來的版本中得到解決,但現在,避免使用「M5」里程碑。 – guenhter

+0

謝謝,我認爲最新版本永遠是最好的。現在讓我們的火狐狸拿起我的規格。感謝您的幫助 –