I have a JUnit4
test suite and I want to execute it under the JUnit Plug-in Test
run configuration.
It passes successfully when running through the JUnit Test
configuration, but for plug-in conf it fails in different ways.
For example if I use JUnit4TestAdapter
it fails with ClassCastException
, and if I trying to run it only through the @RunWith
annotation it wrotes "No methods found" error. For both implementations I use JUnit4
Test Runner setting inside run configuration.
I use
- Eclipse Neon.1a Release (4.6.1)
- Jdk 1.8
- linking JUnit 4.1 lib to the plugin.
For first case it seems that Eclipse proceed to use the JUnit3 version when executing the suite. Here it is:
@RunWith(Suite.class)
@SuiteClasses({ DndTest.class })
public class JSTestSuite {
public static Test suite() {
return new JUnit4TestAdapter(JSTestSuite.class);
}
}
And exception is:
java.lang.ClassCastException: junit.framework.JUnit4TestAdapter cannot be cast to junit.framework.Test
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:403)
While starting the test I have a strange log message in console:
!ENTRY org.eclipse.update.configurator 2017-05-04 17:58:57.279
!MESSAGE Could not install bundle ../../platform/eclipse/plugins/org.eclipse.jdt.junit4.runtime_1.1.600.v20160505-0715.jar No match is available for the required execution environment: J2SE-1.5
I see this lib is on the place, but I can't understand why it failing to be loaded. For JUnit3
Test Runner setting junit3 lib is loaded ok.
There are some bugs related to such issues (like this) but it is really hard to understand what can I do in this case.
For second case I just try to execute simple JUnit4
case without using the JUnit4TestAdapter
, but it can't find any methods.
Reloading of eclipse and renaming of the methods didn't help. What can I do in this case?