我正在運行Android工作室的JUnit測試,這太棒了。如何配置簡單的android工作室來運行JUnit測試
爲了做到這一點,我只好打了一下,並添加以下到VM選項,因爲添加的junit 4.12至依賴於項目結構的應用沒有工作的。
我的問題是:爲什麼,我做錯了什麼?
-ea -classpath "C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\junit\junit\4.12\2973d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;D:\Program Files\Android\Android Studio\lib\idea_rt.jar;D:\Program Files\Android\Android Studio\plugins\junit\lib\junit-rt.jar;D:\Android\sdk\platforms\android-21\android.jar;D:\Android\sdk\platforms\android-21\data\res;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\classes\test\debug;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\classes\debug;C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\1.0\9b473564e792c2bdf1449da1f0b1b5bff9805704\objenesis-1.0.jar;C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\libs\internal_impl-21.0.3.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\classes.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\res;D:\Android\sdk\extras\android\m2repository\com\android\support\support-annotations\21.0.3\support-annotations-21.0.3.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v13\21.0.2\libs\internal_impl-21.0.2.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v13\21.0.2\classes.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\support-v13\21.0.2\res;C:\Users\obfuscated\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\1.9.5\c3264abeea62c4d2f367e21484fbb40c7e256393\mockito-core-1.9.5.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\cardview-v7\21.0.2\res;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\exploded-aar\com.android.support\cardview-v7\21.0.2\classes.jar;D:\Android\projets\AndroidStudioProjects\ElevationDrag\Application\build\intermediates\mockable-android-21.jar"
如果我按照給定的here指示,我發現自己有以下錯誤:
!!! JUnit version 3.8 or later expected:
java.lang.RuntimeException: Stub!
at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:5)
at junit.textui.TestRunner.<init>(TestRunner.java:54)
at junit.textui.TestRunner.<init>(TestRunner.java:48)
at junit.textui.TestRunner.<init>(TestRunner.java:41)
at com.intellij.rt.execution.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:190)
at com.intellij.rt.execution.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:173)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Process finished with exit code -3
@Yu韓:如果你仔細閱讀我的問題,你會發現,我已指示到你給出的鏈接。我可能做錯了什麼。我找到了解決辦法,所以沒關係。但我更喜歡理解信仰,因此我的問題。 –