Ade*_*erd 1 java intellij-idea maven kotlin junit5
我有一个使用JUnit 5.2.0的Kotlin项目。当我使用IntelliJ运行测试时,它会运行所有测试,甚至包括带有注释的测试@org.junit.Ignore。
package my.package
import org.junit.Ignore
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class ExampleTests {
@Test fun runMe() {
assertEquals(1, 1)
}
@Test @Ignore fun dontRunMe() {
assertEquals(1, 0)
}
}
Run Code Online (Sandbox Code Playgroud)
谁能向我解释为什么会这样?
找出答案:JUnit5 将 JUnit4 替换@Ignore为@Disabled.
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
class ExampleTests {
@Test fun runMe() {
assertEquals(1, 1)
}
@Test @Disabled fun dontRunMe() {
assertEquals(1, 0)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
286 次 |
| 最近记录: |