Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My Eclipse can no longer run (or debug) my JUnit tests

I use Eclipse IDE: Eclipse Java EE IDE for Web Developers. Version: Indigo Release

I use JUnit 4. For project properties> Java Build Path> Libraries: I have JUnit4 added. Also under the same tab: Maven Dependencies> I have junit-4.8.2.jar

In pom.xml I have:

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.8.2</version>
  <scope>test</scope>
</dependency>

Basically, I’m writing unit tests using JUnit in the past few months! All I needed to do was to create a test class, add a test method like below:

@Test
public void testMethod(){
    // Some test code
}

Right click on method, Run As> JUnit Test

That’s all I needed to do to either run my unit test or do Debug As> Junit Test to debug my unit test.

All was fine with the world! Starting yesterday, when I add a new test method in a class I already have and then do: Right click on method, Run As> JUnit Test

Nothing happens! I cannot run or debug any test anymore! Meaning I cannot add any new unit test!

Let me also add that I do a clean build thru Eclipse and Eclipse sees the newly complied class which contains my new test method.

Since none of my configurations changed, I have no idea what went wrong!

Does anybody has any idea? Any help would be greatly appreciated.

C:\Project>mvn eclipse:eclipse
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-pl
ugin/2.3.2/maven-jar-plugin-2.3.2.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plu
gin/2.3.2/maven-jar-plugin-2.3.2.pom (6 KB at 10.9 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugin
s/21/maven-plugins-21.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins
/21/maven-plugins-21.pom (13 KB at 27.8 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/20/mave
n-parent-20.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/20/maven
-parent-20.pom (25 KB at 50.3 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-pl
ugin/2.3.2/maven-jar-plugin-2.3.2.jar
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plu
gin/2.3.2/maven-jar-plugin-2.3.2.jar (32 KB at 71.4 KB/sec)
[INFO]

[INFO] Building myProject 3.0

[INFO] >>> maven-eclipse-plugin:2.8:eclipse (default-cli) @ myProject >>>
[WARNING] The artifact commons-email:commons-email:jar:1.1 has been relocated to
org.apache.commons:commons-email:jar:1.1
[INFO]
[INFO] --- xmlbeans-maven-plugin:2.3.3:xmlbeans (default) @ myProject ---
[INFO] All schema objects are up to date.
[INFO]
[INFO] <<< maven-eclipse-plugin:2.8:eclipse (default-cli) @ myProject <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.8:eclipse (default-cli) @ myProject ---
[INFO] Using Eclipse Workspace: null
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER
[WARNING] While downloading commons-email:commons-email:1.1
This artifact has been relocated to org.apache.commons:commons-email:1.1.
Commons Email has been reassigned to the
org.apache.commons group as per the Maven 2 standards.

[INFO] Creating maven-eclipse.xml Ant file to handle resources
[INFO] Creating external launcher file
[INFO] File C:\myProjectProject\.project already exists.
Additional settings will be preserved, run mvn eclipse:clean if you want
old settings to be removed.
[INFO] Wrote Eclipse project for "myProject" to C:\myProjectProject.

[INFO] BUILD SUCCESS

[INFO] Total time: 6.823s
[INFO] Finished at: Tue Mar 13 13:16:52 PDT 2012
[INFO] Final Memory: 9M/152M
like image 776
blueSky Avatar asked Mar 13 '12 17:03

blueSky


2 Answers

My advice is reinstall Eclipse, some config must have broken. Chuck Norris can figure out these problems very quickly but for the rest of us reinstall is usually a good way to go.

like image 58
jabal Avatar answered Sep 18 '22 20:09

jabal


I got this working by recreating the workspace - not able to figure out what was wrong with it. Just here making a note that reinstalling eclipse is not needed, the problem is with a corrupt workspace.

like image 20
eis Avatar answered Sep 22 '22 20:09

eis