我正在尝试使用junit-toolbox中的WildcardPatternSuite
,但测试套件失败了
java.lang.Exception: failed to scan C:\Users\ms\workspaces\comet4\PubServerTests\build\com\priint\pubserver\tests\testsuites using wildcard patterns [**/*Test.class] -- org.junit.runners.model.InitializationError
at org.junit.runners.model.InitializationError.<init>(InitializationError.java:32)
at com.googlecode.junittoolbox.WildcardPatternSuite.findSuiteClasses(WildcardPatternSuite.java:128)
at com.googlecode.junittoolbox.WildcardPatternSuite.getSuiteClasses(WildcardPatternSuite.java:54)
at com.googlecode.junittoolbox.WildcardPatternSuite.<init>(WildcardPatternSuite.java:180)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:33)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
代码是
package com.priint.pubserver.tests.testsuites;
import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/*Test.class"})
public class AllTests {}
测试类位于com.priint.pubserver.
以下的包中,称为*Test
,即EntityTest
。
我正在使用Eclipse 4.3并使用“Run As - &gt; JUnit Test”启动测试套件
这里有什么问题?
编辑:似乎模式"**/*Test.class"
确实从当前包开始,即它在当前包“之上”的包中找不到类。是否存在一种遍历“向上”的模式?
答案 0 :(得分:4)
将您的类移动到一个包,该包是由测试套件运行的所有类的超级包。