org.junit.jupiter.api.Test
这个单元测试框架,不允许@Test 标注的方法所在的类存在有参构造器,一旦存在,便报一下错误:
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.lang.String arg0] in constructor [public com.pig.spring.AppMain(java.lang.String)].
另外,该测试框架也不允许有多个构造器,如果存在多个构造器,则报一下错误
rg.junit.platform.commons.PreconditionViolationException: Class [com.pig.spring.AppMain] must declare a single constructor
综上所述,junit 单元测试框架,只能存在无参构造器
最后
以上就是清爽花瓣最近收集整理的关于junit只能有无参构造器的全部内容,更多相关junit只能有无参构造器内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复