![]() ![]() Has the Paparazzi plugin applied to it.Depends on the StageStepBar module (which is the one under test).So with all that out of the way, here is the full process I followed: Writing tests (Recording process)įirst of all, I created a simple library module. Also at the time of writing again, there was no Compose support. So it might be that what you see here may not work the same in a few months. Complete documentation is not fully there and stuff seems like it is still being worked on. It is worth noting that at the time of writing (12th of Feb 2022) the library is not stable yet. This was really convenient for my use case as it meant that I could use Github Actions to create a way for both me and any future contributors to get some fast feedback on whether their changes broke something. This talk from the same Droidcon goes into more detail about how it works. This is yet another snapshot testing library but the difference with other currently available solutions (see Shot for example) is that it runs completely on the JVM without the need of a device or emulator. ![]() However, a specific library that was showcased at that event called Paparazzi actually convinced me that it is. This seemed like just the right approach for my use case. Otherwise, the code is breaking some things that it shouldn’t. If these changes are expected/desired, the screenshots will be replaced.If any changes are made, a verification algorithm (usual pixel by pixel comparison) runs through your code and compares the golden values with the new screenshots.If you are happy with them you store them in someplace in your repo as golden values/sources of truth.You take a bunch of screenshots and/or videos of your UI.While attending Droidcon 2021 London I got introduced to another way of testing things in the Android world - snapshot testing. What happens with different ones? RTL locales? The list could go on… This whole thing still involved one device.Other times I would not test some cases that would seem irrelevant but would be “mysteriously" affected.Sometimes I would forget to retest some cases.But even that process was not bulletproof enough as: I did thankfully include a sample application but I essentially had to modify, build and run the application to check that my changes were affecting the library in the correct way. It is really a big Custom View with most of its code inside its onDraw.Īll seemed fine and dandy until I realized that the way I could test it after changing stuff was very cumbersome. It is also quite configurable, effectively allowing you to change the look and behavior of all its components. It is essentially a progress bar that can contain Stages (milestones) and individual steps between them. The problem I had to sort was trying to test my library StageStepBar. This is especially true on Android UI libraries where things like Unit testing or UI testing (using Espressο, UiAutomator) start to make less sense. No matter how important it is though, testing sometimes can be inherently difficult. Testing should be the most important thing a dev thinks about while writing (or attempting to write) shippable code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |