Martin Schröder Martin Schröder - 1 year ago 93
Java Question

WildcardPatternSuite finds no classes

I'm trying to use the

WildcardPatternSuite
from junit-toolbox, but the testsuite fails with

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)


The code is

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 {}


The test classes are in packages below
com.priint.pubserver.
and are called
*Test
, i.e.
EntityTest
.

I'm using Eclipse 4.3 and starting the test suite with "Run As -> JUnit Test"

What's wrong here?

Edit: It seems the pattern
"**/*Test.class"
does start at the current package, i.e. it finds no classes in packages "above" the current package. Is there a pattern that traverses "up"?

Answer Source

Move your class to a package that is a super package of all the classes that shall be run by the test suite.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download