Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple annotations passed in am command not working as expected #1794

Open
innovater21 opened this issue May 5, 2023 · 5 comments
Open

Comments

@innovater21
Copy link

innovater21 commented May 5, 2023

Description

If we pass multiple annotations in the am command, it runs all the tests instead of running only the tests with annotation.
Espresso documentation for multiple annotations - https://developer.android.com/reference/androidx/test/runner/AndroidJUnitRunner

Steps to Reproduce

  1. Add annotations to your test functions ( @annotation1, @Annotation2 )
  2. Run the am instrument command
  3. adb shell am instrument -w -e annotation com.android.foo.Annotation1,com.android.foo.Annotation2 com.android.foo/androidx.test.runner.AndroidJUnitRunner

Expected Results

It should only run functions with the annotations. So if have 10 tests in total and we added annotation to only 2 , it should run 2/9 tests

Actual Results

It runs all the tests in the testsuite

AndroidX Test and Android OS Versions

com.android.foo/androidx.test.runner.AndroidJUnitRunner`
Android OS - 13

Note

This works fine with single annotation param

adb shell am instrument -w -e annotation com.android.foo.Annotation1 com.android.foo/androidx.test.runner.AndroidJUnitRunner

Link to a public git repo demonstrating the problem:

@TWiStErRob
Copy link
Contributor

Try removing the space after the comma.

@innovater21
Copy link
Author

@TWiStErRob it was a markdown space formatting issue. Edited description

Had run this command only

adb shell am instrument -w -e annotation com.android.foo.Annotation1,com.android.foo.Annotation2 com.android.foo/androidx.test.runner.AndroidJUnitRunner

TWiStErRob added a commit to TWiStErRob/repros that referenced this issue May 5, 2023
@TWiStErRob
Copy link
Contributor

I played around a bit and discovered that the behavior you describe happens (maybe not exclusively!) when the fully qualified class name is wrong, see https://github.com/TWiStErRob/repros/tree/main/espresso/instrument-annotations.

If this doesn't help, I think the repo owners will need a repro as the behavior seems correct in the repro above.

@innovater21
Copy link
Author

innovater21 commented May 5, 2023

Thanks @TWiStErRob . Will try reproducing this in the same manner

@brettchabot
Copy link
Collaborator

further to what @TWiStErRob stated, I'd suggest to also look at the logcat to see if there are any errors loading annotation classes. If there is an error loading an annotation class, an error will be logged and the '-e annotation' argument will be ignored.
https://cs.android.com/androidx/android-test/+/master:runner/android_junit_runner/java/androidx/test/internal/runner/TestRequestBuilder.java;drc=bdf7d5b385929998d9d0ed1b68c379b74e0d0d55;l=912

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants