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

Inept stubbing in ProjectsDataRepositoryTest #3

Open
chetdeva opened this issue Jun 28, 2018 · 1 comment
Open

Inept stubbing in ProjectsDataRepositoryTest #3

chetdeva opened this issue Jun 28, 2018 · 1 comment

Comments

@chetdeva
Copy link

private fun stubBookmarkProject(completable: Completable) {

Issue: 2 tests were failing

  1. bookmarkProjectCompletes

You should be using factory.getCacheDataStore().setProjectAsBookmarked(any()) instead of cache.setProjectAsBookmarked(any())

private fun stubBookmarkProject(completable: Completable) {
       whenever(factory.getCacheDataStore().setProjectAsBookmarked(any())).thenReturn(completable)
}
  1. unbookmarkProjectCompletes

Same

@chetdeva chetdeva changed the title Inept stubbing Inept stubbing in ProjectsDataRepositoryTest Jun 28, 2018
@arthlimchiu
Copy link

arthlimchiu commented Jul 2, 2018

@chetdeva You can also do this

private fun stubBookmarkProject(completable: Completable) {
        whenever(store.setProjectAsBookmarked(any()))
                .thenReturn(completable)
    }

    private fun stubUnBookmarkProject(completable: Completable) {
        whenever(store.setProjectAsUnbookmarked(any()))
                .thenReturn(completable)
    }

Because stubbing for data stores are already handled in these methods

private fun stubFactoryGetDataStore() {
        whenever(factory.getDataStore(any(), any()))
                .thenReturn(store)
    }

    private fun stubFactoryGetCacheDataStore() {
        whenever(factory.getCacheDataStore())
                .thenReturn(store)
    }

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