Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit4 + Eclipse "An internal error occurred during Launching"

I'm trying to run JUnit4 test cases on Eclipse 3.4.2 but it's not even starting for me. I have the junit-4.7.jar in my build path and the test application.

Here is a simple example that illustrates my problem

package test;
import org.junit.Before;
import org.junit.Test;

public class UTest {    
    @Test
    public void test() {
    }

    @Before
    public void setUp() throws Exception {
    }
}

This compiles fine

Then I do "Run JUnit Test case" from Eclipse and I get an error dialog with this message

"Launching UTest' has encountered a problem
An internal error occurred during: "Launching UTest".
java.lang.NullPointerException

What causes these NullPointerExceptions? What am I doing wrong?

like image 575
Mike Avatar asked Aug 09 '09 03:08

Mike


People also ask

How do I get JUnit to work in Eclipse?

In Eclipse, you create a JUnit test case by selecting in the main window menubar File -> New -> JUnit Test Case. Once you clicked on the item, a big dialog should pop out. In the pop up you can choose the JUnit version (4 is the one we use) and the package and class name of your test case.

Does JUnit work with Eclipse?

JUnit simplifies the Unit testing process in Java with visual indicators and a Unit testing framework. JUnit use in the Eclipse IDE is convenient and quick to configure.

Why my JUnit is not showing in Eclipse?

If you right click in Project Explorer and choose New, you see a much shorter menu that doesn't include the Junit option. Needs to be done in Package Explorer view...

How do I fix an internal error in Eclipse?

ini does no do the trick , best way will be to close any other applications running , after that open Task Manager , and close JAVA services running . Restart the eclipse . NOTE :- This will close the programs using Java if they are open .


2 Answers

What worked for me after trying everything:

  1. Go to help
  2. Install New Software
  3. Work with: Juno
  4. Programming languages (expand it)
  5. Install Java Development Tools
  6. Restart

It works :)

like image 181
Joaquin De La Sierra Avatar answered Sep 20 '22 11:09

Joaquin De La Sierra


I was able to fix this just by deleting the workspace and the Eclipse directory and starting over.

like image 41
Mike Avatar answered Sep 21 '22 11:09

Mike