4

我正在尝试使用WildcardPatternSuitefrom junit-toolbox,但测试套件失败了

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 -> JUnit Test”启动测试套件

这里有什么问题?

编辑:似乎该模式"**/*Test.class"确实从当前包开始,即它在当前包“上方”的包中找不到任何类。是否存在“向上”遍历的模式?

4

1 回答 1

4

将您的类移动到一个包,该包是应由测试套件运行的所有类的超级包。

于 2014-05-02T15:21:39.410 回答