Why is my test not working

The strangest thing is that my test passed fine, and now it's gone. I have not changed the code at all, this is the exception:

Class not found com.example.test
java.lang.ClassNotFoundException: com.example.test
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
+3
source share
5 answers

I see that you are using Eclipse, but are you also using another external build / testing tool like Ant or Maven? Eclipse can sometimes go out of sync when using other external tools.

If you use external tools, do whatever is necessary to clean up the created artifacts (for example, mvn clean). Then upgrade your Eclipse project and perform a clean build as suggested earlier. Then try using unit test with Eclipse again.

Good luck and hope this helps.

+3

JVM . . , com.example.Test?

0

JUnit. classpath, resotre default entries , . , junit , .

0

, - (, Selenium server). , " " ( → " " → " " ) , ( , " " ). , / , Ant. , , :)

WBR,

0

If you use maven to create your project, it puts all the compiled java classes in a folder of type target / classes and Test classes under the target / test classes. So I think eclipse will not be able to find classes from target / test classes. If you want to run JUnit classes from Eclipse, use Eclipse-> Project-> clean, and then you will have all the classes with the same purpose configured in eclipse.

0
source

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


All Articles