Vikram
Vikram

Reputation: 778

Getting Class not found in module 'app'

I'm getting below error while unit testing-

    Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

Project structure is- enter image description here

After some investigation in Run Configuration came to know its taking wrong module(main.java.com.example.dexter.sunshine.app) while running this unit case. How can we change this module?

Upvotes: 4

Views: 13803

Answers (2)

Eric Francis
Eric Francis

Reputation: 24297

I had a similar issue trying to run a groovy test suite.

Try right clicking the java directory under src/androidTest/java and choosing mark directory as -> test sources root

Upvotes: 6

m.hashemian
m.hashemian

Reputation: 1826

I had the same problem and had to look for this for a little bit, and here is what I found.

Go to Run -> Edit Configuration ... to open Run/Debug Configurations.

From there you can either modify your current configurations (whether for JUnit, Android Tests, or Android Application), or you can add a new one as you need. I am sure you can change the class name there.

Upvotes: 4

Related Questions