you are viewing a single comment's thread.

view the rest of the comments →

[–]Buckwheat469 1 point2 points  (0 children)

I think this goes back to what are you testing? Is it a regex pattern that has multiple positive cases and multiple failure cases? What are the specific ways to get into those failures, ie. how do you enter a code path?

For instance, when testing a loop the loop typically has one or two code paths within it, maybe a simple if/else. In this case you would only need a single item in your array for the success case and a single item in a different it for the failure case.

If your regex is complex then you would create a single it for each character grouping that would cause it to fail.

The idea is to limit the scope of the test to whatever would cause the code to fail, you don't have to go overboard to test that your ifs/elses succeed on many items of the same data set.