I've recently been tasked with testing some COM objects of the desktop app I work on. What this means in practice is writing a large number (>100) unit tests to test different but related methods and objects. While the unit tests themselves are fairly straight forward (usually one or two Assert()-type checks per test), I'm struggling to figure out the best way to write these tests in a coherent, organized manner. What I have found is that copy and Paste coding should be avoided. It creates more problems than it's worth, and it's even worse than copy-and-paste code in production code because test code has to be more frequently updated and modified. I'm leaning toward trying an OO-approach using but again, the sheer number makes even this approach daunting from an organizational standpoint due to concern with maintenance. It also doesn't help that the tests are currently written in C++, which adds some complexity with memory management issues. Any thoughts or suggestions?
What Are Some Tips For Writing A Large Number of Unit Tests?
testing;unit testing;maintenance
Any thoughts or suggestions?Focus on one test at a time. Be consistent from one test to the next. Reevaluate your approach once you have ~10 tests under your belt. Realistically, 100 unit tests at ~6-10 lines of code a piece is like a week's worth of work. Annoying, tedious work... but not a lot of it. Put your head down and don't over-think things.