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
static use of Android classes fails with ParameterizedRobolectricTestRunner #3805
Comments
This is still present in 4.2:
.
|
Can you post a sample code showing how the same code works with RobolectricTestRunner? IIUC, this issue is unfortunately expected in Robolectric. The sandboxed classloader is set up before each test method, so accessing any Android classes statically before a test runs is not going to work. |
Is there any plan to support this feature? |
Hi, is there any actual progress on this issue? This is still present in 4.6.1. https://github.com/robolectric/robolectric/blob/master/robolectric/src/test/java/org/robolectric/ParameterizedRobolectricTestRunnerClassLoaderTest.java
error log:
Test environmentRobolectric: 4.6.1 |
@song-water You need to change the type of |
@SpaceBison I tested your occasion with latest Robolectric, and I can get proper main looper value with |
I was trying to get parameterized tests working with robolectric in our project and I saw it fail when using In my case, I can reproduce this with the latest Robolectric version ( I also tried playing with |
Description
I want to write a parameterized test whose data includes Android classes (android.location.Location), specifically. It appears, though, that ParameterizedRobolectricTestRunner installs the classloader too late, because if I create the test data objects in
public static Collection<Object[]> data()
, I get an exception saying the relevant method was not mocked (meaning the class loaded wasn't Robolectric's).The same thing (creating a Location in a static block) succeeds with RobolectricTestRunner.
Test source code
Robolectric & Android Version
3.6.1 & 23
The text was updated successfully, but these errors were encountered: