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
No Dagger2 generated files for JUnit tests #125
Comments
For me it works when adding dagger 2 with both apt and testCompile scopes. BTW, it would be great if we could have an example of testing with Dagger 2. It's not obvious at all to figure out how module can be overiden. |
Can you please provide an example project? I tried to add dagger compiler as a testCompile dependency but without success. |
I'm also running into this issue. An example project or a few pointers would be helpful. Thanks! |
That dependencies {
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
// Additional for unit tests
testProvided 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
} |
Can you please provide an example project? I would like to see the whole project configuration related to JUnit tests. |
Our recommendation for Android Studio is to use https://bitbucket.org/hvisser/android-apt as described above. I'm going to close this. If you are still encountering it when using the apt plugin, and after updating all dependencies, please re-open this, but point to either a github repo with an example project, or a gist containing a failing test, or something so we can reproduce this. |
Here is the AndroidStudio example project: https://github.com/westward/Dagger2Test |
@cgruber why use android apt plugin ? Gradle and Android Studio are supposed to have annotation processor support out of the box, no ? |
@stephanenicolas So you want an |
And it also makes the generated sources visible to the IDE automatically. |
OK guys, what's wrong with my example project? What I've missing? I can't use Dagger2 in tests, I didn't configured project well, something else? Any advice or hint please! |
A new AndroidStudio 1.1 version introduced the unit testing support. This URL http://tools.android.com/tech-docs/unit-testing-support provides step-by-step instruction how to setup IDE to run JUnit tests for Android project.
android-apt plugin by Hugo Visser works nice in assisting of creation Dagger2 generated files for usual Android code but unfortunately there is no generated files for any JUnit test class. I tried to configure dependency like androidTestApt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT' (and tried to specify 'testCompile' and 'provided' too) according to android-apt plugin documentation but without success.
I think the problem is in different sources directory for Unit tests - it's src/test/java instead of src/androidTest/java that used by android instrumentation tests.
Can you please provide any help how to resolve this trouble? I can't understand where is the problem: in the wrong project configuration, a bug in new Android Studio's JUnit tests feature, something wrong in Dagger2 or in android-apt plugin. When needed, I can provide the simple AndroidStudio project to reproduce the trouble.
Thanks in advance.
The text was updated successfully, but these errors were encountered: