-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ParameterizedRobolectricTestRunner
doesn't seem to work with Android classes in real projects
#8815
Comments
I just tried returning a lambda so the parameters are only evaluated after all the Robolectric test runner, shadowing and classloader setup is done and now it's working properly. Could it be that it's working in the test project because it somehow has access to the Android classes in some way that's not available in other projects? |
@jmartinesp I would recommend avoiding Android objects as parameters using ParameterizedRobolectricTestRunner. ParameterizedRobolectricTestRunner is particularly finicky for these types of issues. For instance, instead of Uris, you can have parameters be strings and create the Uris in the test methods. I have not studied the bytecode generated for the test class, but if you are seeing errors such as |
Thanks for your reply: we might be able to work around this issue in some instances by doing what you suggest, but I don't think it'll work for some of our use cases. We'll have to study how much effort we'd need to do to refactor our parameters. That said, should this test be deleted then from the project? It was added here as proof that using Android APIs in the parameters like |
Description
As I was trying to get some screenshot testing with Roborazzi working and passing some data as parameters, I realised I was running into errors saying some Android classes couldn't be found. I found #3805 and the test added to verify this worked fine with Kotlin so I tried creating a new project and copying that single test, and I found out it didn't pass and had the same error messages:
I was quite surprised because the same test obviously passes inside this project, but I couldn't find what's causing it to fail in external projects.
Steps to Reproduce
ParameterizedRobolectricTestRunner
.Robolectric & Android Version
Robolectric version: 4.11.1 (latest).
Android version: API 34.
Link to a public git repo demonstrating the problem:
https://github.com/jmartinesp/RobolectricParameterizedTest
The text was updated successfully, but these errors were encountered: