Jef*_*rod 10 junit android scala sbt sbt-android-plugin
我为我的应用程序开发了一小部分用Scala编写的Android测试,它使用了Robotium库.该套件适用于所有目的和标准的Android JUnit测试项目,并且如果从Eclipse启动,则可以成功运行.
我已经用sbt android-plugin成功构建并运行我的主要Android应用程序.主要应用程序位于[ProjectDir]/src/main.我还能够成功构建位于[ProjectDir]/tests/src/main目录中的Android测试应用程序.我检查了模拟器,测试应用程序似乎已经使用android-plugin tests/android:install-emulator命令正确安装.但是,当我尝试通过运行测试项目时sbt tests/android:test-emulator,我得到:
...
Test results for InstrumentationTestRunner=
Time: 0.001
OK (0 tests)
Run Code Online (Sandbox Code Playgroud)
我怎样才能让sbt android-plugin认识到该项目包含JUnit测试并运行它们?
这里使用的命名约定与普通 JUnit 相同,因此您需要将测试命名为 xxxTest.class。他们还需要扩展 TestCase(AndroidTestCase、InstrumentationTestCase 等...)。
重申一下,Eclipse 将运行如下命令:
adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
它将把类名称附加到命令中,因此命名约定可能不适用。
如果你从 sbt 运行,它就会运行
adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
它将找到应用程序 com.android.foo 的包名下的所有类,并以 someClassNameTest 结尾。
| 归档时间: |
|
| 查看次数: |
781 次 |
| 最近记录: |