2.5. Refactoring to parameterized tests

All the tests you’ve written so far suffer from some maintainability problems. Imagine that now you want to add a parameter to the constructor of the LogAnalyzer class. Now you’d have three noncompiling tests. Going in and fixing 3 tests might not sound so bad, but it could easily be 30 or 100. When it comes to the real world, developers feel they have better things to do than to start chasing the compiler for what they thought should be a simple change. If your tests break your sprint, you might not want to run them or even might want to delete annoying tests.

Let’s refactor them so that you never come across this problem.

NUnit has a cool feature that can help a lot here. It’s called parameterized tests ...

Get The Art of Unit Testing, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.