JUnit4 in Eclipse

I am trying to run some JUnit test modules in Eclipse 3.5, but to no avail.

JUnit3 is working fine.

When I create the JUnit4 testing module, Eclipse suggests adding the JUnit library to the classpath. I accept, but when I check to see if it has been added to the project properties panel, I see that JUnit4 has been added, but JARS is where it was included.
If I select Change , the message " JUnit 4 " appears in the line and just below " Current location: not found ."

When I run the JUnit4 test, I get an error message and an internal NullPointerException error occurs .

I read for about two days, and all the links say that the eclipse includes JUnit4, but it seems like I'm missing something.

I tried unsuccessfully to recreate my projects and create a test in new ones.

package test;

import static org.junit.Assert.*;

import org.junit.Test;

public class AuthServiceTest {

    @Test
    public final void testValidateCredentials() {
        fail("Not yet implemented"); // TODO
    }

}

[edit]

I added junit-4.8.1.jar to the project classpath and eclipse classpath, but the problem is still the same.

[Edit2]

I also added junit-dep-4.8.1.jar, since I'm not sure if these dependencies are needed, but without changes.

+4
source share
3 answers

It seems that Eclipse 3.5 from the Fedora repository does not include JUnit, and installing the corresponding package also does not include it.
Another Debian computer presented the same problem. A clean download from eclipse.org solved the problem.

I will talk about this error at some point :)

0

.

Built Path--> Add Libraries

(JUnit 4 ).

+6

My Eclipse installation provides JUnit 4, in the plugins \ org.junit4_4.3.1 \ junit.jar

If you cannot find it, I think you may need to download it.

You can associate your JUnit with the Eclipse JUnit settings in

Windows->Preferences->Java->Build Path->User Libraries

Select JUnit and you can add and edit the JAR.

+1
source

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


All Articles