-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run single test that inherits all test methods with surefire #1499
Comments
Duplicate of #1406 ? |
It does look like a duplicate. Sorry I did not check existing issues. |
7 tasks
Closing this issue as a duplicate of #1406. |
Appears so, but I have not verified it.
If the above is true, then yes. 😉 |
neo-technology-build-agent
pushed a commit
to neo4j/neo4j
that referenced
this issue
Sep 6, 2018
Because changes introduced as part of junit-team/junit5#1499 new junit is not compatible in a way with surefire test runner and its impossible now to invoke single test using -Dtest option. Exception that we get when we do that with new junit version is something like: java.lang.NoSuchMethodError: org.junit.platform.engine.support.descriptor.MethodSource.from(Ljava/lang/Class;Ljava/lang/reflect/Method;)Lorg/junit/platform/engine/support/descriptor/MethodSource; at org.junit.vintage.engine.descriptor.VintageTestDescriptor.toMethodSource(VintageTestDescriptor.java:155) at org.junit.vintage.engine.descriptor.VintageTestDescriptor.toTestSource(VintageTestDescriptor.java:138) at org.junit.vintage.engine.descriptor.VintageTestDescriptor.<init>(VintageTestDescriptor.java:54) at org.junit.vintage.engine.discovery.TestClassRequestResolver.addChildrenRecursively(TestClassRequestResolver.java:110) at org.junit.vintage.engine.discovery.TestClassRequestResolver.createCompleteRunnerTestDescriptor(TestClassRequestResolver.java:93) at org.junit.vintage.engine.discovery.TestClassRequestResolver.determineRunnerTestDescriptor(TestClassRequestResolver.java:64) at org.junit.vintage.engine.discovery.TestClassRequestResolver.createRunnerTestDescriptor(TestClassRequestResolver.java:59)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello JUnit team,
I noticed that running a single test which inherits all test methods does not work with Maven.
JUnit 5.3.0-M1, surefire 2.22.0.
Base test class:
child class:
Maven command
mvn test -Dtest=ConcreteTest
.Surefire provider is now part of the surefire plugin but this issue might be JUnit related. I think this is what happens:
ConcreteTest#theTest()
MethodBasedTestDescriptor
is created withMethodSource
as its test sourceMethodSource
is created usingMethodSource#from(Method)
and the discoveredConcreteTest
class is not usedMethodSource
constructor tries to figure out the class name usingmethod.getDeclaringClass().getName()
MethodSource
is for classAbstractTestBase
and method#theTest()
TestMethodFilter
tries to matchMathodSource(AbstractTestBase, theTest)
with "**/ConcreteTest"AbstractTestBase#theTest()
andConcreteTest#theTest()
is the same thingRunning
mvn test -Dtest=ConcreteTest
results in an error saying "No tests were executed!".Command
mvn test -Dtest=ConcreteTest,AbstractTestBase
can be used as a workaround. It results in a single executed test, as expected.Problem can be fixed by making constructor of
MethodBasedTestDescriptor
useMethodSource#from(String className, String methodName)
static factory instead ofMethodSource#from(Method)
. This preserves "ConcreteTest" name for future checks executed by surefire.VintageTestDescriptor
also usesMethodSource#from(Method)
and might have the same problem.Example project from this gist can be used to reproduce the problem.
I'd be happy to provide a fix for this problem if it is really in JUnit code and my findings are correct.
Thanks in advance!
The text was updated successfully, but these errors were encountered: