Snapshot android8/30/2023 ![]() They used some cool tricks taken out of the world of functional programming and made the library easily extendable for a lot of use-cases but more on these tricks later. Point-Free is a great video series on practical functional programming in Swift and in this video, they showcase their snapshot testing library. The amazing guys from Point-Free implemented a small and flexible snapshot testing library in Swift. That’s why snapshot testing is always a great addition to your test suite but not a replacement. Snapshot testing just recognizes if something changed and cannot tell if something is correct or not. With that, we also have to mention one of the issues with snapshot testing: You don’t test the logic of your code directly. You don’t need to think about the logic behind it and can avoid regression bugs. With snapshot testing, you can very quickly define test cases. Sounds good in theory? You will be surprised by how easy it is to implement this in practice. Now you can decide how to deal with the change! Either the change was expected and you store a new reference or you go back and fix the issue until the screen matches the reference again. Example – Visualization of what has changed If something changes and for instance, the screen looks different, the test case fails and shows you the difference to the original screenshot. ![]() On every following run of your test suite (hopefully conveniently on a CI), the property is checked against the reference. By recording this property (aka taking a screenshot) on the first run of your test case, a reference is saved. You define a test case for a property of your application that can be serialized, for example, a screenshot of your main screen. Wouldn’t it be cool to have a convenient and easy way to find such regressions quickly and keep track of UI changes? Snapshot testing solves this by automatically comparing the previous and the new build. ![]() Something like this is easily overseen in manual testing since the QA would need to test the change on every device. Probably every mobile developer knows these small but annoying bugs: The general toolbar of the app is restyled, and it looks good on 29 out of the total 30 screens but on one of the screens some UI elements moved unnoticed onto the wrong positions. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |