Unit Testing as a Delegation Tool

Unit Testing as a Delegation Tool

Delegation is hard. There are a variety of reasons, but there are two things I’ve heard quite often from customers, and they are related. They have trouble specifying and clearly communicating the exact requirements to the person they are delegating to. They also have trouble verifying that whatever code is produced actually meets the requirements.

Google returns over 40M pages talking about how hard delegation is.

Unit Testing can solve both of these problems. Creating a set of Unit Tests for a module clearly specifies exactly what the module is supposed to do in various situations. You can then pass those specifications off to another developer and have them fill in the details of the module. When they return and say they are done, how do you verify that everything works as expected? Simply run the Unit Tests.

This unit test clearly specifies that when passed methods with the same parameters whose names differ only in case, Verify Call.vi should output true.

We can extend this and make our development process even more robust by incorporating gitflow, Vi Analyzer, and Continuous Integration. When you delegate a task to someone, you first write the API and a set of unit tests. You create a branch for them to work in their own little sandbox. You add Unit Tests and a VI Analyzer test, because simply making it work is not good enough. We need our code to be readable and maintainable as well. Then you set up CI to run both tests whenever they push. Now you turn them loose. When they are done, they submit a merge request. Your job just got easier. You have an instant litmus test to decide if you should even bother considering the merge request. If the CI pipeline fails, you can just immediately reject it. The server does it all for you, you don’t even have to bother running the tests yourself.