question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android Library seemingly can't filter Instrumented tests via @Tag

See original GitHub issue

I’m trying to prototype a simple Hello World gradle android library project to get the @Tag filtering working with some tests. After some amount of hunting around, I got this working with unit tests (though as an aside, https://github.com/mannodermaus/android-junit5/wiki/Migrating-from-1.0.x is a bit obscure and should probably be pulled into the main wiki pages, e.g. android.testOptions.junitPlatform.filters.tags.include having been moved to <...>.filters.includeTags was a pain point). Thus running e.g. ./gradlew clean test is now successfully only running tests tagged with @Tag('sampleTag').

However, instrumentation tests are still all being run regardless of the filter, e.g. ./gradlew clean connectedAndroidTest runs both tests regardless of the @Tag('sampleTag')

The following is my build.grade:

build.gradle.txt

and my project is laid out with unit tests in src/test/java and instrumentation tests in src/androidTest/java. This is the current instrumentation test file I’m running:

StupidConnectedTest.java.txt

Is this not currently supported, or am I missing some separate place where filters on instrumentation tests need to be defined, or a gradle dependency, etc?

Please and thanks for any help!

EDIT: Sorry Tom g, didn’t mean to tag you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mannodermauscommented, Jul 8, 2019

connected tests (but not unit tests) seem to run one ‘null’ test instead of saying ‘0 tests run’

I’ve seen this as well, but debugging the events sent to the RunNotifier, there are no superfluous messages sent to the build tool. As far as I know, this should be an IDE issue, unfortunately.

Thanks again for providing the sample info! This should be helpful for others seeking to be at the forefront of this stuff as well.

Any idea when a non-snapshot for this version will be released?

There’s a couple of tweaks I’d like to apply to the new support (in terms of DSL) before submitting the final release. No hard promises, but I’m aiming for the end of this week ~ I’ll keep you posted!

any idea how to reduce instrumentation test output verbosity as mentioned above?

Unfortunately not from the perspective of preventing these logs from being emitted. You could raise the log level of Logcat or apply a filter to the output, I suppose.

0reactions
mannodermauscommented, Jul 14, 2019

This has been released with Gradle Plugin 1.5.0.0 and android-test-runner 1.1.0. Note that you need to update both coordinates to make use of this, and also I’d like to reiterate that the filtering only works for @Tag-based filters for now. Feel free to open a new issue if you run into any problems!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build instrumented tests | Android Developers
Instrumented tests run on Android devices, whether physical or emulated. As such, they can take advantage of the Android framework APIs.
Read more >
Targeting an Application Example
When the instrumentation is invoked via am instrument command, the framework restarts com.android.shell process, and injects instrumentation ...
Read more >
Test from the command line | Android Developers
Run specific test methods or classes​​ To learn more about using the --tests flag, read Gradle's documentation on test filtering. Note: To run ......
Read more >
JUnit tests missing test resources in classpath - Issue Tracker
When running JUnit tests from Android Studio (for non-Android code) it doesn't automatically add the test resources directory to the ...
Read more >
Android 13 changelog: A deep dive by Mishaal Rahman
Android 13 is now publicly available, Google shared multiple preview builds so developers can test their applications. The early preview builds provided an ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found