From time to time when writing tests in Swift you may encounter situations where network requests are needed as apart of test.
Network requests can cause tests to run slowly and make them more brittle due to potential network or service issues.
The team behind the ArcGIS Maps SDK for Swift implemented an internal tool that allows network requests in Swift tests to be recorded and played back during subsequent test runs. This capability takes network instability out of the equation and allows tests to run much more quickly and reliably.
This tool has been used for a few years with much success in stabilizing the tests and reducing failures. Recently we’ve taken the tool open-source making it available to any Swift developer – meet Dejavu.
Dejavu is already helping us in other areas. In our open-source toolkit we’ve used it to shave seconds of run time off of network dependent unit tests.
Dejavu is available now as a Swift package for use in your own Swift projects and applications.