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

Could I get an example of FragmentTest with viewModel injected instead of mocked? #2

Open
di0n0s opened this issue Sep 5, 2019 · 2 comments

Comments

@di0n0s
Copy link

di0n0s commented Sep 5, 2019

Hi,

First of all, thank you very much for this repository. It´s very didactic and helps a lot to understand Android development with Jetpack.

I´m trying to testing one of my fragment without mocking viewModel because I need to do an acceptance test but I don't know why viewModel is not injecting. I think because I must setup dagger ready to use on espresso testing.

How would you setup your project to inject dependencies on espresso tests? Could I get an example of your "VideoListFragmentTest" with viewModel injected instead of mocked on a branch?

Thanks in advance!

@jeppeman
Copy link
Owner

Hi there!

Sorry for the late response, been out of the loop for a while. Glad the project has been of some help to you.

It sounds like you want to do an integration or end to end test; In this case you do not really want to incorporate the viewmodel in your test, you'd rather want to just use the espresso API:s to do things such as view actions / assertions or intent stubbing. Have a look at this test and see if that makes any sense. It basically clicks an item in the video list and checks that the detail page is displayed.

@di0n0s
Copy link
Author

di0n0s commented Dec 5, 2019

Hi there,

Sorry for delaying answering this! I had a release and I t was a really crazy month. Could you upload again the link with the example test? I get a 404 now.

Thanks in advance.

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