Today, I looked at the data-driven unit tests I had written nearly four weeks ago. It took me a couple of minutes to understand the tests again. Understanding my own tests should have been much easier.
Data-driven unit tests in QTest have a fundamental problem. The data goes in one function, say
testWriteFrame_data, and the test case working on the data goes in another function, say
testWriteFrame. I must go back and forth to understand the test case. While going back and forth, I typically forget one piece of information. So, I must do another round trip.
So, I sat down and converted each row of the table created by
testWriteFrame_data into a test function of its own. The resulting test cases are much easier to understand. They have about the same code size as the original solution. But see for yourself.