2012-06-21 247 views
3

我希望能夠運行在命令行JUnit測試,但是當我運行此命令運行Android的JUnit測試

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

所有我得到的回覆是

OK (0 tests) 

不它與它是一個Android項目有關嗎?我之前運行過這個命令,並沒有太多問題。

回答

8

我剛剛設法從命令行運行JUnit測試,但使用了adb shell。

的命令是

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

更多細節here

+0

這已經成爲我的最終解決方案。我只是不明白爲什麼Junit亞軍將無法拿起它。但無論我想什麼作品。 – ZacAttack

+1

我想'com.dddforandroid.api'是你的自定義包在這裏,與測試? – n611x007