简体   繁体   English

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

[英]Unit tests not running after updated to 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.我一直在 Android Studio Bumblebee 做项目,该项目包含几个包,其中一些有使用 Junit 和 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但是在更新到 Android Studio Chipmunk 之后,在我排除任何 package 或任何 class 文件并再次运行之后,没有任何测试用例运行并显示此消息

Test events were not received未收到测试事件

I also tried adding the classes that I need coverage, still the same issue.我也尝试添加我需要覆盖的类,仍然是同样的问题。

As a workaround you may run the tests through the gradle task window:作为一种解决方法,您可以通过 gradle 任务窗口运行测试:

Use the command that you used for your run configurations:使用您用于运行配置的命令:

gradle testDebugUnitTest --tests "your.package*"

在此处输入图像描述

Add in your module build.gradle testImplementation project(":name-of-your-module") .添加你的模块 build.gradle testImplementation project(":name-of-your-module")

It's a workaround!这是一种解决方法!

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.截至今天,我更新到最后一个 AS - Chipmunk Patch2,AGP 到 7.2.2 和 Gradle 到 7.3.3,问题已修复,没有任何其他更改 r 解决方法。 Seems that the bug has been fixed.好像bug已经修复了。

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.在运行/调试配置中,使用加号按钮添加一个新的“Gradle 配置”。
  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.在运行文本框中添加以下testDebugUnitTest --tests "com.example.*"其中 com.example 是您在所有模块中通用的命名空间,将.*留在最后,这是秘诀。
  4. In the Gradle project box ensure that the root gradle build file is selected.在 Gradle 项目框中,确保选择了根 gradle 构建文件。
  5. Click apply/ok then select the config and run.单击应用/确定,然后单击 select 配置并运行。

It should all work just fine now...or maybe not depending on any tests failing;)它现在应该一切正常......或者可能不取决于任何失败的测试;)

if you use Kotlin, check your "build.gradle" file and add apply "kotlin-android" plugin.如果您使用 Kotlin,请检查您的“build.gradle”文件并添加应用“kotlin-android”插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio Chipmunk 自动创建模块后无法解析测试中的生产代码 - Cannot resolve production code in tests after Android Studio Chipmunk automatically created modules Android 工作室,花栗鼠,蓝牙,Java - Android Studio, Chipmunk, Bluetooth, Java 将 android studio 升级到 Android Studio Chipmunk 后 | 2021.2.1 得到这个 gradle 问题 - After upgrading android studio to Android Studio Chipmunk | 2021.2.1 getting this gradle issue 如何构建我的 Android Studio 项目以避免在运行集成了单元测试的应用程序时出现编译问题 - How do I structure my Android Studio project to avoid compilation issues with running the app with unit tests integrated Android Studio Gradle单元测试不起作用 - Android Studio Gradle Unit Tests Not Working Android Studio - 单元测试模拟应用重启 - Android Studio - Unit Tests Simulate App Restart 在使用Android Studio保存时运行单元测试 - Run unit tests on Save with Android Studio 使用 Spock 框架运行 Android 单元测试 - Running Android unit tests with Spock framework 更改后运行单元测试不会在 IntelliJ 中运行更新的测试 - Running a unit test after changing it does not run the updated test in IntelliJ 在Android中更新后,Eclipse无法运行项目 - Eclipse is not running projects after once updated in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM