更新到Android Studio Chipmunk后未运行的单元测试

发布于 2025-01-30 20:15:28 字数 261 浏览 3 评论 0原文

我一直在Android Studio Bumblebee中从事项目,该项目包含多个软件包,其中一些包含使用Junit和Mockito的测试课程。
因此,在提高代码覆盖范围的时,我在调试配置中排除了带有零单位测试的软件包。但是在更新到Android Studio Chipmunk之后,在我排除任何软件包或任何类文件并再次运行之后,没有运行所有测试用例,并且显示此消息

未收到测试事件

我也尝试添加类别我需要覆盖范围,但仍然存在同样的问题。

I have been working on project in Android Studio Bumblebee, and the project contains several packages , some of them have test classes using Junit and Mockito.
So inorder to increase code coverage, I had excluded the packages with zero unit tests in Debug configurations . But after updating to Android Studio Chipmunk, after I exclude any package or any class file and run again, none of the test cases are run and shows this message

Test events were not received

I also tried adding the classes that I need coverage, still the same issue.

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

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

发布评论

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

评论(5

站稳脚跟 2025-02-06 20:15:28

作为解决方法,您可以通过gradle任务窗口运行测试:

使用用于运行配置的命令:

gradle testDebugUnitTest --tests "your.package*"

“在此处输入图像说明”

As a workaround you may run the tests through the gradle task window:

Use the command that you used for your run configurations:

gradle testDebugUnitTest --tests "your.package*"

enter image description here

清泪尽 2025-02-06 20:15:28

添加您的模块build.gradle tistImplementation项目(“:您的模型名称”)

这是一个解决方法!

Add in your module build.gradle testImplementation project(":name-of-your-module").

It's a workaround!

Oo萌小芽oO 2025-02-06 20:15:28

我遇到了同样的问题。截至今天,我更新到last -as -chipmunk patch2,AGP至7.2.2和gradle至7.3.3,问题已解决,而没有任何其他更改r解决方案。似乎该错误已解决。

I was having the same problem. As of today I updated to last AS - Chipmunk Patch2, AGP to 7.2.2 and Gradle to 7.3.3, the problem was fixed, without any other change r workarounds. Seems that the bug has been fixed.

别挽留 2025-02-06 20:15:28

在海豚工作很好。要重现成功执行以下操作:

  1. 在Run/Debug配置中,使用Plus按钮添加了新的“ Gradle配置”。
  2. 在“名称文本”框中给它一个名称(例如,“所有单元测试”),
  3. 在运行文本框中添加以下testDebugunitTest -tests -tests“ com.example。*”其中com.example是您的在上使用的命名空间common所有模块,在结尾处留下。*,这是秘密调味料。
  4. 在Gradle项目框中,请确保选择root Gradle构建文件。
  5. 单击应用/确定,然后选择配置并运行。

现在所有的工作都可以正常工作...或者可能不依赖任何测试失败;)

Works in Dolphin just fine. To reproduce success perform the following:

  1. In Run/Debug Configurations add in a new "Gradle Configuration" using the plus button.
  2. Give it a name in the name text box ("All Unit Tests" for example)
  3. In the run text box add the following testDebugUnitTest --tests "com.example.*" Where com.example is your namespace common across all modules, leave the .* at the end, this is the secret sauce.
  4. In the Gradle project box ensure that the root gradle build file is selected.
  5. Click apply/ok then select the config and run.

It should all work just fine now...or maybe not depending on any tests failing ;)

各自安好 2025-02-06 20:15:28

如果使用Kotlin,请检查您的“ build.gradle”文件,然后添加应用“ Kotlin-android”插件。

if you use Kotlin, check your "build.gradle" file and add apply "kotlin-android" plugin.

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