Unit testing is an important part of a sustainable development process because it enables developers to prevent regressions.
Things get complicated when the code you are testing communicates with an Azure service over a network. How can you reliably test code with external dependencies?
One option is to provision required Azure resources and run tests using them.
This is expensive because every developer needs their own set of resources. It’s slow because having every test communicate over a network makes them take longer. It’s hard to manage because resources have to be in a specific state before starting a test.
A better option is to replace the service clients with mocked or in-memory implementations. This avoids the above issues and lets developers focus on testing their application logic, independent from the network and service.
In this article, we’ll show you how to use the Azure SDK to write great unit tests that isolate your dependencies to make your tests more reliable.