码迷,mamicode.com
首页 > 其他好文 > 详细

【Junit 报错】Test class should have exactly one public zero-argument constructor和Test class can only have one constructor

时间:2016-12-21 16:29:09      阅读:3074      评论:0      收藏:0      [点我收藏+]

标签:build   ssr   pen   play   ima   image   splay   lin   runners   

错误1:

技术分享
 1 java.lang.Exception: Test class should have exactly one public zero-argument constructor
 2     at org.junit.runners.BlockJUnit4ClassRunner.validateZeroArgConstructor(BlockJUnit4ClassRunner.java:171)
 3     at org.junit.runners.BlockJUnit4ClassRunner.validateConstructor(BlockJUnit4ClassRunner.java:148)
 4     at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:127)
 5     at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
 6     at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
 7     at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
 8     at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
 9     at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
10     at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
11     at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
12     at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
13     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
14     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
15     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
16     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
17     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
18     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
19     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
View Code


解决:
测试类必须有一个无参数的public构造函数

 

错误2:

技术分享
 1 java.lang.IllegalArgumentException: Test class can only have one constructor
 2     at org.junit.runners.model.TestClass.<init>(TestClass.java:48)
 3     at org.junit.runners.ParentRunner.createTestClass(ParentRunner.java:88)
 4     at org.junit.runners.ParentRunner.<init>(ParentRunner.java:83)
 5     at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
 6     at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
 7     at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
 8     at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
 9     at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
10     at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
11     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
12     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
13     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
14     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
15     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
16     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
17     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
View Code

 

解决:

未解决!!!

【Junit 报错】Test class should have exactly one public zero-argument constructor和Test class can only have one constructor

标签:build   ssr   pen   play   ima   image   splay   lin   runners   

原文地址:http://www.cnblogs.com/sxdcgaq8080/p/6207944.html

(2)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!