Android 安卓浓缩咖啡;“未发现任何测试”&引用;“进程崩溃”;
在用Espresso测试我的Android应用程序时,我注意到运行配置了Android 安卓浓缩咖啡;“未发现任何测试”&引用;“进程崩溃”;,android,android-espresso,Android,Android Espresso,在用Espresso测试我的Android应用程序时,我注意到运行配置了All-in-Module的AndroidTest找不到任何测试,而运行All-in-Package成功 我创建了以下可复制的案例: 使用向导创建带有minSdk 8和空活动的新的clean应用程序 将gradle配置为浓缩咖啡依赖项等(见下文) 使用选项创建AndroidTest运行配置,使用选项所有模块创建AndroidTest运行配置,并使用所有模块 添加带有测试的类(见下文) 使用包中的所有组件运行:测试通过 使用
All-in-Module
的AndroidTest找不到任何测试,而运行All-in-Package
成功
我创建了以下可复制的案例:
- 使用向导创建带有minSdk 8和空活动的新的clean应用程序
- 将gradle配置为浓缩咖啡依赖项等(见下文)
- 使用选项创建AndroidTest
,使用选项运行配置
创建AndroidTest所有模块
,并使用运行配置
所有模块
- 添加带有测试的类(见下文)
- 使用包中的所有组件运行:测试通过
- 使用
:未找到任何测试全部输入模块运行
全功能模块运行
还可以正常工作。我记得所做的更改是将Android Studio升级到1.4,将Android支持库升级到23.1.0,将Android支持库升级到24.0.0
顺便说一句,gradlew connectedCheck
和gradlew createDebugAndroidTestCoverageReport
立即失败
有人对解决这个问题有什么建议吗
应用程序的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.xyz.apptest"
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
androidTestCompile('com.android.support.test.espresso:espresso-idling-resource:2.2.1') {
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.4.1') {
// Necessary if your app targets Marshmallow (since the test runner
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:rules:0.4.1') {
// Necessary if your app targets Marshmallow (since the test runner
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
}
Test.java
@RunWith(AndroidJUnit4.class)
public class Test1 {
@Rule
public ActivityTestRule<MainActivity> activityTestRule =
new ActivityTestRule<>(MainActivity.class, true, false);
@Before
public void setUp() {
activityTestRule.launchActivity(new Intent());
}
@After
public void cleanUp() {
}
@Test
public void test() {
}
}
logcat:未发现敏感差异。从基于API 10的仿真器切换到API 17修复了该问题
尽管API 10在上周之前运行良好,但它已经变得不可预测。有时它会运行,但大多数情况下不会。删除单个测试方法可能会使其工作,而将其放回原处可能会使其工作(或不工作)。第五次尝试运行测试可能会使它再次工作
更新2016-03-16:
增加API 10模拟器的资源使API 10的测试再次可用…同样的情况也发生在我身上。是否可以在一个模块中运行所有测试用例?@请参阅下面的答案。我在模拟器中增加了ram的数量,突然它工作了。。。正在执行模块中定义的所有测试。
Testing started at 12:14 ...
Waiting for device.
Target device: 3_2_API_10 [emulator-5554]
Uploading file
local path: C:\Users\xyz\Documents\Development\AndroidStudio\AppTest\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.example.xyz.apptest
No apk changes detected.
Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop com.example.xyz.apptest
Uploading file
local path: C:\Users\xyz\Documents\Development\AndroidStudio\AppTest\app\build\outputs\apk\app-debug-androidTest-unaligned.apk
remote path: /data/local/tmp/com.example.xyz.apptest.test
No apk changes detected.
Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop com.example.xyz.apptest.test
Running tests
Test running startedTest running failed: Instrumentation run failed due to 'Process crashed.'
Empty test suite.