conference-app-android
conference-app-android copied to clipboard
Start Writing Tests
Creating a broad ticket to write some tests for our existing functionality. Haven't begun to dug into this so I'm not sure what will happen yet, but this is to track progress.
If you guys aren't opposed, for the user profile/registration stuff I am inclined to write some tests :) I have been into MVP patterns + JUnit + Mockito lately at work, but whatever you guys decide here I'll follow along!
I'm sure Giorgio would appreciate the help! I was going to start by combing through the non UI files first and getting in some basic JUnit tests where I can, and take note of anywhere that can be refactored.
I can defer to you on the login related files for now. :)
Hi. Can I help with this issue?
Sure! Any help is appreciated, we don't have a lot of test coverage yet. Feel free to see #140 for what we have now.
The tests are mostly for data classes. I looked inside the views
package and saw that a lot of it seemed pretty tightly coupled together. It's hard to write unit tests for fragment classes. So I would move forward with a couple options:
- We consider some UI testing and see if we can mock the data layer somehow
- We look for opportunities to move things out of the fragments into a ViewModel class, and write unit tests around the view models.
Personally, I like the second option, but that might be tricky. If we want to do that, I think we can divide the work by package. Example: I could take the detail
package and refactor/test the AgendaDetailFragment and SpeakerDetailFragment.
Does this seem like a good way to split work?
Sorry for the late reply. I would actually like to go with the second approach as it would allow better testability and extensibility in the future. We can use MVVM/MVI to structure the code. Can you tell me whether the speaker module is a good starting point for the same?
Speaker module would be good as well. There wasn't time to do this properly the last two years FYI...it was just "get it working"...usually 2-3 weeks before the event so it was maybe two weekends of work :-)
Haha no worries, we've all been there. Happy to help refactor it now. :)
Have refactored the speaker module using architecture components. Yet to write tests (facing some difficulties with testing along firebase dependencies). Help/reviews welcome https://github.com/GurpreetSK95/conference-app-android/tree/gs/speakers-refactor
What part about testing with firebase? I did some firebase mocking in my branch that's up for PR. Maybe once it's merged you'll have some inspiration? I learned how to mock firebase database calls like this: https://stackoverflow.com/a/43227989/3131147