Community
Participate
Working Groups
see sample code in jdt.ui itself. Eclipse does not find the test class because of the migration from junit 4 to junit 5. https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/165807 Look at org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CallHierarchyTest.java
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/165811
CallHierarchyTest.java can be executed. You have to make sure that you use a junit 5 run configuration. Under some circumstances eclipse generates a junit 4 run configuration if you run the test that does not work. For the linked gerrit it is still not clear why the test testTestAnnotationJunit5() fails. Besides it is strange that since I changed it to use JavaProjectHelper.set18CompilerOptions(fProject); instead of JavaProjectHelper.set15CompilerOptions(fProject); I have to use assertEquals(TestKindRegistry.JUNIT5_TEST_KIND_ID, testKind.getId()); instead of assertEquals(TestKindRegistry.JUNIT4_TEST_KIND_ID, testKind.getId()); I am not sure what these two things have to do with each other. Is this expected?
When I change the code in JunitCore.java like this the test is found: public static IType[] findTestTypes(IJavaElement container, IProgressMonitor monitor) throws CoreException, OperationCanceledException { final Set<IType> result= new HashSet<>(); // JUnit4TestFinder finder= new JUnit4TestFinder(); JUnit5TestFinder finder= new JUnit5TestFinder(); finder.findTestsInContainer(container, result, monitor); return result.toArray(new IType[result.size()]); }
(In reply to Carsten Hammer from comment #3) > When I change the code in JunitCore.java like this the test is found: > > public static IType[] findTestTypes(IJavaElement container, > IProgressMonitor monitor) throws CoreException, OperationCanceledException { > final Set<IType> result= new HashSet<>(); > // JUnit4TestFinder finder= new JUnit4TestFinder(); > JUnit5TestFinder finder= new JUnit5TestFinder(); > finder.findTestsInContainer(container, result, monitor); > > return result.toArray(new IType[result.size()]); > } Looking into the details and history of this method, it was added in bug 243294. The current method is used in JDT for JUnit4TestFinderTest. Please check if you need something similar for your scenario as well.
Carsten, please provide a scenario to reproduce the current problem here with details. Also, explain the proposed solution as adding a reference to JUnit 5 in JUnit4TestFinder does not look correct.
(In reply to Noopur Gupta from comment #5) > Carsten, please provide a scenario to reproduce the current problem here > with details. Also, explain the proposed solution as adding a reference to > JUnit 5 in JUnit4TestFinder does not look correct. You must be right of course... Is it possible that someone takes the time to explain why the new tests part of the gerrit fail without the changes? And I still have no explanation for the strange behavior from comment2. Maybe this gives me some insights.. I derived the tests from the existing junit 4 tests after I experienced problems to execute and still do not get the idea why it is wrong. I saw others having issues with junit 5 too. Unfortunately it is not clear how to reproduce. I can see highly suspicious code like what is mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=570024 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=569848
I will also add the "helpwanted" keyword along with "investigate" so that anyone interested can take a look.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.