2

I'm working on a project defined with maven, and I can successfully run the maven script to build the app, and run automated (junit 3.8.2) tests on the device with instrumentation.

Likewise I can use adb to run the instrumentation tests successfully.

However running the instrumentation tests from IntelliJ is failing with this:

Running tests
Test running startedTest running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
Empty test suite.

Logcat shows the not found class as org.junit.Test. The IntelliJ project was created by importing the root pom, and otherwise works fine. I just had to create a Run Configuration for the tests, specifying the instrumentation runner.

I've tried on several devices and they all provide the same result.

I would expect the junit Test class to be in the OS framework on the device, so I'm confused as to why it's not being found. I've tried setting the junit dependency in IntelliJ from Provided to Compile, but that makes no difference.

What have I missed?

Ollie C
  • 28,313
  • 34
  • 134
  • 217

1 Answers1

0

Okay this is an old question, however, most likely you'll have different classpath in maven as compared to intelliJ. You can solve this pretty easily by going to the intelliJ project Structure ( File --> Project Structure or Ctrl + Alt + Shift + S).

Under Project Settings, click Libraries and manually add the library that is missing.

I do find it strange though that IntelliJ is not picking up maven dependencies. After all, if maven runs it, so should intelliJ - it has the best maven integration available in an IDE and VERY VERY much better than that of eclipse. So your issue does make me feel something else is the root cause...

Perhaps you can ask the IntelliJ people? More info on your part could allow us to give better feedback...

Lawrence
  • 1,035
  • 13
  • 8