【发布时间】:2021-03-05 06:50:36
【问题描述】:
我正在尝试将我们的应用程序从 java-8 迁移到 java-11。我正面临 pojo junit 测试的问题。这适用于 java-8 ,但对于 java-11,pojo 测试类未运行。它看起来下面的依赖项不支持 java 11。
我在 dependencies.gradle 中有以下依赖项
testImplementation("pl.pojo:pojo-tester:0.7.6")
下面是我的 PojoTest 课程
package com.product.model;
import static pl.pojo.tester.api.assertion.Assertions.assertPojoMethodsFor;
import org.junit.Test;
import pl.pojo.tester.api.assertion.Method;
import com.product.CassOne;
import com.product.CassTwo;
import com.product.CassThree;
public class PojoTests {
@Test
public void testPojos() {
final Class<?>[] classesUnderTest = {
CassOne.class,
ClassTwo.class,
ClassThree.class};
for (Class<?> classUnderTest : classesUnderTest) {
assertPojoMethodsFor(classUnderTest).testing(Method.GETTER, Method.SETTER, Method.TO_STRING).areWellImplemented();
}
}
}
我正面临以下错误
java.lang.NullPointerException at the line
assertPojoMethodsFor(classUnderTest).testing(Method.GETTER, Method.SETTER, Method.TO_STRING).areWellImplemented();
欢迎任何我如何解决此问题的建议或任何其他建议。
【问题讨论】:
-
嘿只是好奇,你为什么要测试 pojo 和什么目标测试?
-
该库似乎不再受支持或更新,我建议忽略 pojo 测试
-
我不知道为什么这是在测试 pojo 时实现的。我猜测测试 pojo 以确保其正确实施,并且可能是为了代码覆盖..
-
你可以研究从代码覆盖中忽略 pojo 的方法
标签: unit-testing junit java-11