gpt4 book ai didi

安卓工作室 "No tests were found"

转载 作者:IT老高 更新时间:2023-10-28 22:25:39 25 4
gpt4 key购买 nike

有没有人能够让测试在 Android Studio 中运行(从 GUI 而不是终端),我一直无法从 GUI 运行测试。

每次我尝试通过 GUI 运行测试时,我都会收到以下消息:

enter image description here

我可以使用以下命令从终端运行测试:

./gradlew connectedAndroidTest

我在 Mac OSX

上运行带有 Gradle 1.11 和插件 0.9.0Android Studio 0.5.2

我的项目结构如下;

MyProject/
src/
androidTest/
java/
com.myproject.app.test/
… (tests source code) …
main/
java/
com.myproject.app/
… (source code) …
res/
… (resources code) …
build.gradle

我的 build.gradle 文件类似于以下内容:


android {
compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
versionCode 12
versionName "2.0"
minSdkVersion 9
targetSdkVersion 19
testPackageName "com.test.foo"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
}

如果有人有任何建议,我将非常乐意在这里提出。

最佳答案

今天我在一些 Espresso 测试中遇到了同样的问题,这让我抓狂,因为一切看起来都很正常。最后我发现问题是因为用 @BeforeClass 注释的方法抛出了异常。如果该方法出现问题,异常的堆栈跟踪不会显示在运行选项卡日志窗口中,而是显示在日志窗口Android Monitor 选项卡

如果您想重现问题,只需将其添加到您的测试类中:

@BeforeClass
public static void setupClass() {
throw new RuntimeException("Sorry dude, you won't find any test!");
}

关于安卓工作室 "No tests were found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22582021/

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