编程语言
首页 > 编程语言> > java – WildcardPatternSuite没有找到类

java – WildcardPatternSuite没有找到类

作者:互联网

我试图使用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 – > JUnit Test”启动测试套件

这有什么不对?

编辑:似乎模式“** / * Test.class”确实从当前包开始,即它在当前包“之上”的包中找不到类.是否有一种遍历“向上”的模式?

解决方法:

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

标签:java,junit,junit4,test-suite,filepattern
来源: https://codeday.me/bug/20190624/1280278.html