Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse Junit: java.lang.ClassNotFoundException
Eclipse Junit: java.lang.ClassNotFoundException [message #1792746] Mon, 23 July 2018 13:11 Go to next message
Bruno Pistone is currently offline Bruno PistoneFriend
Messages: 1
Registered: July 2018
Junior Member
I have the following problem:

I have a java project that uses gradle. The project structure is:

src
- main
-- java
-- resources
- test
-- java
-- resources


I have the following test class:

package it.main.tests;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class MainTest {

    @Test
    public void mainTests() {
        String s = "ciao";

        assertEquals(s, "ciao");
    }
}


If I run the following command: gradle test everything is ok. If I try to run the mainTests method from eclipse (right click on the method, Run As, JUnit test) I have the following exception:

Class not found it.main.tests.MainTest
java.lang.ClassNotFoundException: it.main.tests.MainTest
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:770)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:499)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Re: Eclipse Junit: java.lang.ClassNotFoundException [message #1792784 is a reply to message #1792746] Tue, 24 July 2018 03:57 Go to previous message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 80
Registered: February 2010
Location: Bangalore, India
Member
Which version of Eclipse and Junit is being used ? Can you create a bug with all the details ?
https://bugs.eclipse.org/bugs/


Sarika Sinha
JDT Programmer
Previous Topic:not showing maven dependency in eclipse
Next Topic:Resolution of test classes failing when the dependency they originate is Java 9/10 module ?
Goto Forum:
  


Current Time: Mon Nov 19 01:41:56 GMT 2018

Powered by FUDForum. Page generated in 0.01399 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top