Get the latest tech news
Avoiding Test-Case Permutation Blowout
Sometimes you want to write tests for a business rule that's based on multiple variables. Covering every possible permutation of the variables quickly becomes unsustainable. I've found myself using a different approach — one test for the positive case, and one test for each variable's negative case.
In your goal to cover the rule thoroughly, you start writing tests for each permutation of all variables. Write one test that covers the positive case, where all the variables are in the correct state to make the thing happen. The alternate "turn it off one variable at a time" approach results in 4 test cases:
Or read this on Hacker News