6

I have 3 test classes for a particular package from my main application. My first test class is running just fine, the other 2 aren't.

When I try to run those 2 tests, I get the following error:

Instrumentation run failed due to 'java.lang.ClassNotFoundException'

I already verified:

  • if the build path was properly configured,
  • if the target package is correct,
  • if I had problems with importing jUnit.

Any guess about what the problem is?

-----//-----

Solution:

I changed the version of jUnit I was using and the tests perform as they should.

3 Answers 3

11

You need to add JUnit library to your package as following:

On Eclipse, right click on your test project, choose Properties --> Java Build Path, on Order and Export tab, please check on JUnit 4 and click OK.

After that, clean or rebuild your test project and run.

Sign up to request clarification or add additional context in comments.

Comments

1

Java build path should export JUnit 4 library(checked) and Ensure you clean and rebuild the project

Comments

0

have you define your other two class in "AndroidManifest"

1 Comment

In my target project or in my test project? The target already has those classes in its Manifest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.