我們的團隊正在向 Kotlin 邁出第一步,我即將遷移測驗。我嘗試了 mockk 的第一個示例(
(重新啟動 Intellij 沒有幫助,也沒有單獨運行 mvn)
這是我的 maven 依賴項(Intellij 現在顯示錯誤):
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version> <!-- kotlin.version == 1.7.0 -->
<scope>test</scope>
</dependency>
解決方案是(參見熱鍵的答案)添加以下 Maven 依賴項:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
uj5u.com熱心網友回復:
您需要添加對kotlin-test-junit(對于 JUnit 4)、kotlin-test-junit5(對于 JUnit Jupiter)或kotlin-test-testng(對于 TestNG)其中之一的依賴項,具體取決于您使用的測驗框架。
該工件kotlin-test僅包含通用代碼、斷言器和其他可以跨框架重用的東西。
kotlin.test注釋喜歡@Test或作為@BeforeTest測驗框架的實際注釋型別的型別別名在特定于測驗框架的工件中提供。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/497601.html
標籤:行家 科特林 kotlintest
