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

Mockito cannot mock this class: class pl.charmas.android.reactivelocation.ReactiveLocationProvider #195

Open
ArtemNurtdinov opened this issue Oct 12, 2018 · 1 comment

Comments

@ArtemNurtdinov
Copy link

ArtemNurtdinov commented Oct 12, 2018

@Mock lateinit var reactiveLocationProvider: ReactiveLocationProvider
@Mock lateinit var prefs: Preferences
@Mock private lateinit var location: Location

@Before
fun setUp() {
    initMocks(this)
    locationProvider = LocationProviderImpl(reactiveLocationProvider, prefs)

    given(location.latitude).willReturn(FAKE_LATITUDE)
    given(location.longitude).willReturn(FAKE_LONGITUDE)
}

Getting this error

org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class: class 
pl.charmas.android.reactivelocation2.ReactiveLocationProvider.

Using Mockito 2.23.0
Any solutions?

@saadfarooq
Copy link

A workaround is to add the following dependency to the testImplementation configuration.

// hacks to get ReactiveLocationProvider to mock
testImplementation "com.google.android.gms:play-services-places:17.0.0"

It provides the missing class references from ReactiveLocationProvider.

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