Java Android Studio单元测试配置

Java Android Studio单元测试配置,java,android,unit-testing,jenkins,ui-testing,Java,Android,Unit Testing,Jenkins,Ui Testing,有没有办法从命令行运行Android单元测试或配置?目前,“gradle test”运行单元测试测试工件中的所有测试,但这些测试失败并出现错误:“java.lang.IllegalStateException:未注册检测!必须在注册检测下运行。” 我正在寻找一种方法来运行与在android Studio中右键单击com.foo.android(测试)并按“在'com.foo.android'中运行测试”时运行的配置相同的配置?我想把这个搬到詹金斯那里去。或者能够使用我在AS中手动创建的配置 谢谢

有没有办法从命令行运行Android单元测试或配置?目前,“gradle test”运行单元测试测试工件中的所有测试,但这些测试失败并出现错误:“java.lang.IllegalStateException:未注册检测!必须在注册检测下运行。”

我正在寻找一种方法来运行与在android Studio中右键单击com.foo.android(测试)并按“在'com.foo.android'中运行测试”时运行的配置相同的配置?我想把这个搬到詹金斯那里去。或者能够使用我在AS中手动创建的配置

谢谢

[编辑]
如果我将纯junit测试和Instrumentation测试分离到各自的工件中,那么我就失去了自己运行UI测试的能力,有没有办法解决这个问题?我有一个配置,只运行UITest包,但不知道如何从命令行运行此配置。

查看这些配置是否有助于从命令行运行android单元测试:

adb shell am instrument -w <package>/android.test.InstrumentationTestRunner
adb shell am instrument-w/android.test.InstrumentationTestRunner
在子包中运行所有测试用例:

adb shell am instrument -w  <package>.<sub package>/android.test.InstrumentationTestRunner
adb shell am instrument-w./android.test.InstrumentationTestRunner
从测试类运行单个测试用例:

adb shell am instrument -w -e class <project>.<test class>#testCase
<package>/android.test.InstrumentationTestRunner
adb shell am仪器-w-e类.#测试用例
/android.test.InstrumentationTestRunner

我发现最好的方法是将我的所有UITests放在一个包中,当我只想运行单元测试时:

adb shell am instrument -w -e notPackage com.foo.android.UITest com.foo.android.test/android.support.test.runner.AndroidJUnitRunner
要运行所有测试,请运行:

adb shell am instrument -w com.foo.android.test/android.support.test.runner.AndroidJUnitRunner
仅适用于UITest:

adb shell am instrument -w -e package com.foo.android.UITest com.foo.android.test/android.support.test.runner.AndroidJUnitRunner

您是否有插入式测试(如Espresso测试)或纯Java junit测试?两者的混合,它们也不是全部分开的,有些在同一个类中您是否在build.gradle中配置了
TestInstrumentRunner
?TestInstrumentRunner“android.support.test.runner.AndroidJUnitRunner”当前的设置方式这将适用于包,但是是否有方法运行配置,而不是单独指定每个包?如果没有,我可能只需要创建一个专门用于单元测试、InstrumentationTests和UITests的包。