假设我们有以下测试代码:
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
public class NullTest {
@Test
public void testNull() {
doNothing(null);
}
private @NotNull String doNothing(@NotNull String value) {
return value;
}
}
运行
gradle test
时测试将通过直接或如果 IDEA 将操作委托(delegate)给 gradle。但它会失败
IllegalArgumentException: Argument for @NotNull parameter 'value' must not be null
如果它使用 IDEA runner(未委托(delegate)给 gradle)运行,则会出现异常。问题是:如何使使用 gradle 运行它的测试失败?
最佳答案
尝试将以下内容添加到您的依赖项中。它对我有用。
compile 'org.jetbrains:annotations:13.0'
关于java - Gradle 构建忽略 Jetbrains 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48517104/