8000 Hilt with Robolectric · Issue #1959 · google/dagger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Hilt with Robolectric #1959

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

Closed
erzapito opened this issue Jun 29, 2020 · 3 comments
Closed

Hilt with Robolectric #1959

erzapito opened this issue Jun 29, 2020 · 3 comments

Comments

@erzapito
Copy link

Hi, I'm trying to make some tests using robolectric and Hilt and I cannot get dependency injection to work. Same test does work under integration tests.
Is there any test that shows how to integrate this?
I have a simple project for this here:
https://github.com/erzapito/pcremotecontrol/blob/master/app/src/test/java/com/zapo/pcremotecontrol/activities/MainActivityTest.kt

@bcorso
Copy link
bcorso commented Jun 29, 2020

Hi @erzapito

Can you confirm that you've added enableTransformForLocalTests in your build.gradle file:

hilt {
    enableTransformForLocalTests = true
}

@erzapito
Copy link
Author

I'm not sure where to put that, put I tried at "root level" and inside the "android" level

@bcorso
Copy link
bcorso commented Jun 30, 2020

Discussed this with @danysantiago, looks like this is currently the same issue as #1956. I thought the issue only affected bytecode transformation within test sources, but turns out that it also doesn't pick up the bytecode transformed prod sources.

The tl;dr is that we're waiting for b/37076369 to be fixed so that Android Studio properly picks up the transformed sources. But see #1956 for a couple work arounds.

Closing this as a duplicate of #1956.

@bcorso bcorso closed this as completed Jun 30, 2020
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

2 participants
0