gpt4 book ai didi

android - "Empty suite" Espresso 测试

转载 作者:行者123 更新时间:2023-11-28 20:41:11 25 4
gpt4 key购买 nike

我正在尝试运行一个简单的“你好!”测试,但我得到了空的测试服,我可以找到问题这是我的 gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "sku1l.eccc"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
packagingOptions {

exclude 'LICENSE.txt'

}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-annotations:22.2.0'
androidTestCompile 'com.android.support:support-annotations:22.2.0'

androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2'){
exclude group: 'javax.inject'
}
androidTestCompile 'com.android.support.test:runner:0.3'
// androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2'
}

这是测试:

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;




@RunWith(AndroidJUnit4.class)

public class ApplicationTest {


@Rule
public ActivityTestRule<MainActivity> mActivityTestRule= new ActivityTestRule<>(MainActivity.class);

@Test
public void testVisibility() {
onView(withText("Hello"))
.check(matches(isDisplayed()));
onView(withId(R.id.Hello)).check(matches(withText("Hello")));
}

}

这是日志

Success


Uploading file
local path: C:\Users\sku1l\AndroidStudioProjects\elparche\app\build\outputs\apk\app-debug-androidTest-unaligned.apk
remote path: /data/local/tmp/sku1l.elparche.test
No apk changes detected. Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop sku1l.elparche.test
Running tests
Test running startedFinish
Empty test suite.

我还编辑配置并设置特定的仪器运行器:android.support.test.runner.AndroidJUnitRunner

当我这样做时,我会在 logcat 中得到它

Running tests
Test running startedTest running failed: Unable to find instrumentation info for: ComponentInfo{sku1l.elparche.test/android.support.test.runner.AndroidJUnitRunner}
Empty test suite.

我希望你能帮助我...谢谢

最佳答案

好的,我终于找到了解决方案,proguard 是问题所在,您可以在测试时排除或删除 proguard,一切都会正常运行,希望它能帮助更多人

关于android - "Empty suite" Espresso 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31955280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com