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

I am using the Eclipse IDE: Eclipse Java EE IDE for web developers. Version: Indigo Release

I am using JUnit 4. For project properties> Java Build Path> Libraries: I have JUnit4. Also on 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 have been writing block tests using JUnit in the last few months! All I had to do was create a test class, add a test method, as shown below:

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

Right click method, run as> JUnit Test

This is all I needed to do to run my unit test or run Debug As> Junit Test to debug my unit test.

Everything was in order with the world! Starting yesterday, when I add a new testing method to a class that I already have, and then do: Right-click the method, run as> JUnit Test

Nothing happens! I can no longer run or debug any tests! Meaning I cannot add any new unit test!

Let me also add that I am doing a clean build through Eclipse, and Eclipse sees a new class that contains my new testing method.

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

Does anyone have any ideas? 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 
+4
source share
6 answers

I tried many ways ... finally had to uninstall Eclipse and install it again. Jabal: Thanks for the tip! I got Eclipse Indigo for 64 bit; setting this up was also painful! Having received so many errors and installed and uninstalled several times, it turned out that it only works with JDK7! Although the docs mention that it should also work with JDK6, but not for me. In any case, unit testing returned to normal, which is nice.

0
source

My advice is to reinstall Eclipse, some kind of configuration should break. Chuck Norris can quickly solve these problems, but for the rest of us, reinstalling is usually a good way.

+4
source

I got this job by recreating the workspace - I am not able to understand what is wrong with him. Only here, noting that reinstalling eclipse is not needed, is the problem related to a damaged workspace.

+1
source

I had a similar problem after I forced my eclipse to leave. After the junit test cases do not start. He will just say that he finished in 0 seconds. I went to the folder /{workspaceasket/.metadata/.plugin and deleted the junit plugins folder. After restarting eclipse, I was able to run junit test cases.

+1
source

Below my problem was solved in Luna Eclipse.

Go to project properties> Java Compiler> Generating Classfile. You need to check the option "Add line number attributes to generated class files (used by the debugger)."

0
source

I really did not want to dump my workspace and reconfigure a new one. In the end, I discovered why the Eclipse message to run the JUnit tests did nothing without an error message or any obvious key.

Looking at> Build Path> Configure Build Path ...>, I see that my project lists two other projects that I also imported into the IDE, and these projects are currently in a closed state, as seen in Project Explorer view.

Just opening these other projects led my project to respond, as expected, to my requests to run the JUnit test. I believe that I could alternatively remove these projects as the listed dependencies for my current project, "Setting the path to the project." But I have them there, so clicking on the class methods in the code will lead me to this source code, and not to the view. The base code for the .class file.

0
source

Source: https://habr.com/ru/post/1401216/


All Articles