简体   繁体   中英

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.
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.

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*"

在此处输入图像描述

Add in 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. Seems that the bug has been fixed.

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;)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM