Dev Diary - August 2023
If I had to encapsulate the work I did in August it would be "testing". Unit testing, UI testing, end to end testing, you name it I wrote the tests for it for the Bible in a year app.
What I worked on #
I'll start by talking about the work I did that was NOT testing. A few years ago during the height of its popularity, I made a clone of the popular Wordle game for my wife to play on her phone. Here's a link to the repository. In addition to the "Daily" mode that everyone was using on the website, I also added an "Practice" mode that let you play the game over and over again whenever you wanted. Since then she has switched to using a iPhone mini (and I can't blame her, that size is to die for!) so she had asked if I could make it work on her Chromebook. So this past month I added support for keyboard input, added tweaks for a better large screen experience, and did some performance fixes (specifically around recompositions now that I know more about working in Compose). Overall, not a lot of work, but the app runs substantially better now and looks very passable on a large screen!
The rest of the month was spent working on wrapping up the Bible in a year app, namely finishing up all the testing work I wanted to do and adding better support for TalkBack. I achieved 100% coverage for all my domain layer code and solid coverage of most other code through unit testing while not leveraging Robolectric or a mocking framework. I was then able to test the rest of my scenarios using end-to-end tests which used the real data and stores for highly trustworthy tests. On the accessibility front, I put in a lot of effort to ensure that the app was fully traversable and read in a natural voice.
Key Learnings #
- Testing State Holders - I need more experience testing state holders. I found myself caught between writing end-to-end style tests that replicated a lot of the UI tests I had already written and writing unit style tests that test the output for a given input but required a lot of setup.
- UI Testing in Compose - UI testing in Compose is a breeze compared to using Espresso. The tests are easy to write with the verbose
SemanticMatchersystem and a ton of support for performing actions on nodes. I never found myself stuck unable to perform the tests I wanted to perform.
- Testing with Hilt - I still highly prefer Dependency Injection over Service Location, but I can say with certainty after working with Koin at work vs Hilt for personal projects that replacing types for testing is far easier in Koin. At one point I wanted to replace the list of 365 readings with a shorter list to test getting to the complete state. It ended up being far easier to just have the test click the button 365 times instead of setting up a component to inject the specific type I wanted for the test.
- Prefer "Dumb" UI - In the course of sprinkling
stringResourcecalls all throughout my UI, I am leaning farther toward putting all the data including display strings and content description strings into the state holder. This way the UI can be "dumb" only taking in state and emitting action to be performed on state instead of having little bits of state sprinkled throughout the UI.
- Accessibility Highs and Lows - It was great, and fairly easy, to transform the data into descriptions that read like natural human language. For example "Genesis 12:15-13:20" originally read as "Genesis 12 colon 15 minus 13 colon 20", but was updated to "Genesis chapter 12 verse 15 through chapter 13 verse 20". However, there is no way to help TalkBack with pronunciation. So "Job 1-2" reads Job as "j-ah-b" like a career instead of "j-oh-b" like the book of the Bible.
What's Next #
With the Bible in a year app all wrapped up, I can finally start working on the "distraction free" browser in earnest. You can check out my description of it in my last dev diary if you want to know more. This month will be focused on setting up a foundation to build on while testing mvp builds on my personal device to see what works and what doesn't. In my next dev diary, I hope to have a more concrete idea of what I want to finish for the final MVP of this app.
I'm excited to get back to work on feature dev tasks, but a focus on testing and accessibility was a good reminder to both do the work as you go instead of jamming it in at the end and how important those tasks are for a fully featured application. Until next time, thanks!
Did you find this content helpful?
Please share this post and be sure to subscribe to the RSS feed to be notified of all future articles!
Want to go above and beyond? Help me out at one of the services below, it goes a long way in helping run this site. Thank you in advance!