-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Running JUnit 3 test suite with JUnit Vintage engine with Gradle #2904
Comments
The following all-in-one test class runs fine for me in the Eclipse IDE using JUnit 3, JUnit 4, and JUnit 5. package example;
import org.junit.runner.RunWith;
import org.junit.runners.AllTests;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@RunWith(AllTests.class)
public class JUnit3Test extends TestCase {
public JUnit3Test(String name) {
super(name);
}
public static TestSuite suite() {
var suite = new TestSuite("JUnit 3 style test suite");
suite.addTest(new JUnit3Test("JUnit 3 style test") {
@Override
protected void runTest() {
testSomeLibraryMethodReturnsTrue();
}
});
return suite;
}
public void testSomeLibraryMethodReturnsTrue() {
Library classUnderTest = new Library();
assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod());
}
public static class Library {
public boolean someLibraryMethod() {
return true;
}
}
} Thus, I suspect it is an issue with Gradle. @marcphilipp, thoughts? |
Sorry for the very late reply. This issue seems to have fallen through the cracks. 😕
I suspect so as well. I somewhat inelegantly verified the test is actually executed when run via Gradle by adding
I debugged your reproducer for a bit and this hints at the problem. The Vintage engine creates |
Running a JUnit 3 test annotated to be run with the
AllTests
runner using JUnit 5 may not actually run the test.Steps to reproduce
In our project we have quite a few JUnit 3 tests looking like:
Currently, we're executing them using JUnit 4, but I'm trying to move to JUnit 5. When I change to
useJUnitPlatform()
in the Gradle build file these tests are no longer executed.There's a full working example in https://github.com/ulrikls/junit-vintage-alltests
Any of these changes will successfully execute the JUnit 3 test:
useJUnit()
instead ofuseJUnitPlatform()
.JUnit 3 style test
totestSomeLibraryMethodReturnsTrue
.@RunWith(AllTests.class)
annotation and thesuite()
method.I don't know if this example is even supposed to work in JUnit 5, there doesn't seem to be a lot of documentation on running JUnit 3 tests with JUnit 5. But migrating all our JUnit 3 tests is also not trivial, as the tests currently do various stuff in the
suite()
method.Context
The text was updated successfully, but these errors were encountered: