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

Doesn't work with Robolectric unit tests #43

Open
MuntashirAkon opened this issue May 20, 2021 · 2 comments
Open

Doesn't work with Robolectric unit tests #43

MuntashirAkon opened this issue May 20, 2021 · 2 comments

Comments

@MuntashirAkon
Copy link

MuntashirAkon commented May 20, 2021

You'd get the following error if you use Robolectric for unit testing. The current workaround is to catch IllegalStateException.

java.lang.IllegalStateException: Already initialized
at com.yariksoffice.lingver.Lingver$Companion.init(Lingver.kt:192)
at com.yariksoffice.lingver.Lingver$Companion.init(Lingver.kt:182)
at com.yariksoffice.lingver.Lingver.init(Lingver.kt)

This happens because Robolectric calls Application#onCreate() on each test.

@Grch
Copy link

Grch commented Aug 4, 2021

Have you found any workaround? I can't launch unit tests

@MuntashirAkon
Copy link
Author

Have you found any workaround? I can't launch unit tests

Create a custom Application test class for Robolectric tests.

@MuntashirAkon MuntashirAkon changed the title Doesn't work with Roboelectric unit tests Doesn't work with Robolectric unit tests Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants