Advise about testing lots of cases

In my application I have an ADT with 9 leaf level classes.
The classes implement several methods to define the interaction between the different leaf class.
This means there are lots of special cases.
For each special case, I try to have at least one (if not multiple) test cases to cover that special case.

Is there a convention to associating some lines of code with a particluar test case and vice versa.
I.e., when I (or someone else) looks at the test case, I might like to know, which special case is this testing exactly? And when I look at a piece of code, I might like to know which test case covers it.

If I relate them by line number, of course that would be bad, as line numbers change.
I’ve thought about just putting comments like ;; Case 1121 and ;; test for Case 1121.
Is there a better way?

I’d try to come up with some concise vocabulary at the conceptual level and name classes, methods and test cases accordingly. (If this vocabulary doesn’t pre-exist for the given domain, it may have to be documented separately.) Comments tend to become outdated pretty quickly during refactorings in my experience, and I also would expect at least some special cases to arise from interactions between classes/methods and thus not be easily mapped to a single line of code…

1 Like

Indeed, that is true. some cases arise from discovering them using randomized testing.