I am test driving a method which is parameterized by two inputs and depends on a Strategy. Here's what I have:
[TestCase(input_a1, input_b1, strategy1)]
[TestCase(input_a2, input_b1, strategy1)]
[TestCase(input_a3, input_b1, strategy1)]
[TestCase(input_a1, input_b2, strategy1)]
[TestCase(input_a2, input_b2, strategy1)]
[TestCase(input_a3, input_b2, strategy1)]
[TestCase(input_a1, input_b1, strategy2)]
[TestCase(input_a2, input_b1, strategy2)]
[TestCase(input_a3, input_b1, strategy2)]
[TestCase(input_a1, input_b2, strategy2)]
[TestCase(input_a2, input_b2, strategy2)]
[TestCase(input_a3, input_b2, strategy2)]
My test method looks like this:
[TestCase(expected, input_a3, input_b2, strategy2)]
void TestMethod(Output expected, Input a, Input b, Strategy strategy)
{
var TestObject = new TestObject(strategy);
var actual = testObject.TestMethod(a, b);
// Assert expected == actual
}
It's not hard to imagine how I got here. I started by varying input_a
and keeping input_b
and strategy1
constant, ending up with 3 test cases.
[TestCase(input_a1, input_b1, strategy1)]
[TestCase(input_a2, input_b1, strategy1)]
[TestCase(input_a3, input_b1, strategy1)]
Then I copied those test cases and varied input_b
with the other two constant, multiplying my test cases.
[TestCase(input_a1, input_b2, strategy1)]
[TestCase(input_a2, input_b2, strategy1)]
[TestCase(input_a3, input_b2, strategy1)]
Then I varied the strategy
, again multiplying my test cases.
[TestCase(input_a1, input_b1, strategy2)]
[TestCase(input_a2, input_b1, strategy2)]
[TestCase(input_a3, input_b1, strategy2)]
[TestCase(input_a1, input_b2, strategy2)]
[TestCase(input_a2, input_b2, strategy2)]
[TestCase(input_a3, input_b2, strategy2)]
I feel that my test cases are growing at an alarming rate. Now I need to add a third Strategy
. If I continue like this, I would be adding another set of test cases. If I added another input, input_c
, I would multiply my sets of test cases by at least 2.
Is it too verbose to test every combination of input_a
, input_b
, and strategy
?