ZacAttack
ZacAttack

Reputation: 2027

Running Android Junit tests from command line

I want to be able to run Junit tests from the command line, but when I run this command

java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name]

All I get back is

OK (0 tests)

Does it have something to do with it being an Android project? I've run that command before and haven't had much issue.

Upvotes: 4

Views: 13716

Answers (2)

0x8BADF00D
0x8BADF00D

Reputation: 7718

Template:

adb shell am instrument -w <YOUR_PACKGE_NAME>.test/android.support.test.runner.AndroidJUnitRunner

Example:

adb shell am instrument -w com.example.android.testing.blueprint.flavor2.test/android.support.test.runner.AndroidJUnitRunner

Details on Google's github page: Android Testing Blueprint

Upvotes: 0

andreea.sandu
andreea.sandu

Reputation: 222

I just managed to run JUnit tests from command line, but using an adb shell.

The command was

./adb shell am instrument -w com.dddforandroid.api/android.test.InstrumentationTestRunner

More details here.

Upvotes: 9

Related Questions