When I run just my Testclass in Eclipse I get the JUnit view showing the tree structure and if the test was successful. If I start my Test from code:
JUnitCore core = new JUnitCore();
core.run(SimpleTests.class);
the view does not show. Can I change this?
On your toolbar click Windows-->Show View-->Others.
Type "Junit" without quotes. Select from list and click OK.
I suppose you run your code in the main method like this example :
public class MiniTest extends TestCase
{
@Test
public void test()
{
System.out.println("Running test");
}
public static void main(String[] args)
{
JUnitCore core = new JUnitCore();
core.run(MiniTest.class);
}
In this case, it will not show your view because you launch your program as a java application (alt-shift-X-J). You will see "Running test" in the console but that is.
If you want to see the Junit View you must launch your program as a Junit test (alt-shit-X-T).
Note that with this manner the main() is not necessary, Eclipse will directly launch the method tagged with @Test. You can also group tests with @Suite.
You can't interact with the JUnit view from your code using JUnitCore.
You can however, add your tests to the JUnitView if you use a @Parameterized test, or if you implement your own test runner. Try extending the Suite class and reimplement one of the constructors with the tests that you want to execute.
I get this problem from time to time.
There is something corrupted in the eclipse workspace.
The only solution for me is to create a new workspace and bring in the projects.
It's a serious pain when there are fifty projects in the workspace.