-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
NPE in Fresco.initialize(this) in the Application when running Robolectric Unit Test #2060
Comments
Try calling https://github.com/facebook/fresco/search?q=setintestmode Let me know if this fixes the issue. We should probably document this somewhere. |
Nop, same error. |
@foghina the problem is that the MainApplication extends Application is called before the setUp (@before) so the SoLoader.setInTestMode() is never been called. Now, I remove the Fresco.Initialize(this) from the MainApplication and set it in the activity and Its working :) but I dont want to call Fresco.initialize(this) in all the activities on my app. Is there any workarround for this situation? Thanks |
Hmm, |
Hi @sdeira Could you replace your default Application class with one used only for the tests? it should be possible using Robolectric: https://stackoverflow.com/questions/21725309/robolectric-not-using-test-application |
@sdeira I know its tricky but I solved it with try-catch.
|
@foghina @BeforeClass is working thanks.
|
@BansookNam thanks for the update! |
@BansookNam
|
@BansookNam @BeforeClass |
@vkotovv Thank you for notice! If not working. I have no Idea how to solve 😢you may use try catch. |
Confirmed that
works for me. |
Is there any reason why This forces consumers to explicitly include the |
TestNativeLoader was added with version 2.1.0 and should be available starting with that version. |
We use GitHub Issues for bugs.
If you have a non-bug question, please ask on Stack Overflow: http://stackoverflow.com/questions/tagged/fresco
--- Please use this template, and delete everything above this line before submitting your issue ---
Description
Im trying to run a unit test using Robolectric ( testImplementation "org.robolectric:robolectric:3.7.1") and a NPE appears when executing Fresco.initialize(this) in the main Application.
This is the code of the test:
Here is the stack:
Reproduction
100%
Solution
[OPTIONAL: Do you know what needs to be done to address this issue? Ideally, provide a pull request which fixes this issue.]
Additional Information
The text was updated successfully, but these errors were encountered: