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

Why is DaggerMock trying to mock all objects in the graph? #94

Open
bnvinay92 opened this issue Jan 24, 2019 · 2 comments
Open

Why is DaggerMock trying to mock all objects in the graph? #94

bnvinay92 opened this issue Jan 24, 2019 · 2 comments

Comments

@bnvinay92
Copy link

Mockito cannot mock/spy because :

  • final class

I have an object that is being passed into a subcomponent with @BindsInstance. DaggerMock is trying to mock this object even though I don't want to mock it in tests, and this is causing my test to crash.

@fabioCollini
Copy link
Owner

Are you sure the error is on the object used in a @BindsInstance annotated method?
However if you are using DaggerMock in a Kotlin project you should consider using something to avoid problems with final methods/classes. More info here: https://github.com/fabioCollini/DaggerMock/#kotlin-support

@bnvinay92
Copy link
Author

bnvinay92 commented Jan 24, 2019

@Subcomponent.Builder
    interface Builder {

        @BindsInstance
        Builder activity(AppCompatActivity activity);

        // Everything breaks when I add the following.
        @BindsInstance
        Builder lifecycleEvents(SomeFinalClassFromALibraryICantMakeOpen object);

        ActivityComponent build();
    }

I'm not trying to mock this final class in my UI tests, so why does it matter if the object being bound is final or not?

mock-maker-inline does not seem to work with androidTests.

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