简单的 JUnit 测试在 Android Studio 中不起作用

发布于 2025-01-14 04:02:58 字数 798 浏览 2 评论 0原文

您好,我正在尝试在 Android Studio 中运行基本的 JUnit 测试。当我单击“运行”时,每次在获得结果之前都会终止。我从来没有通过或失败,系统也不会尝试任何其他测试用例。

这是图片。我想知道为什么它不起作用,以便我可以继续练习。

输入图片此处描述输入图片此处描述输入图片此处描述输入图片此处描述输入图片此处描述

Hi I am trying to run a basic JUnit test in Android Studio. When I click run it is terminated every time before getting results. I never get pass or fail and the system does not try any other test cases.

Here are the pictures. I would like to know why it isn't working so I can keep practicing.

enter image description here
enter image description here
enter image description here
enter image description here
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宛菡 2025-01-21 04:02:58

您可以尝试一些方法

用 @SmallTest 装饰您的测试类

// @RunWith is required only if you use a mix of JUnit3 and JUnit4.
@RunWith(AndroidJUnit4::class)
@SmallTest
class ExampleInstrumentedTest {
}

尝试从命令行运行您的测试:

./gradlew connectedAndroidTest

You can try a couple of things

Decorate your test class with @SmallTest

// @RunWith is required only if you use a mix of JUnit3 and JUnit4.
@RunWith(AndroidJUnit4::class)
@SmallTest
class ExampleInstrumentedTest {
}

Try to run your test from the command line:

./gradlew connectedAndroidTest
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文