This problem arose whilst writing a simple 3D vector class.
The class contained methods (Java, so no operator overloading) for addition, subtraction, multiplication, and division. These methods performed this operation between the instance they were called on, and another vector or single value.
When it came to writing the unit tests, I was unsure how I should approach testing this class.
The three options I could come up with were as follows:
- Test the
Add
,Sub
,Mul
, andDiv
methods separately (two for each, vector and value), with different values for each - Test the methods separately with the same values each time, but different expected results
- Don't test the methods as they are very simple (not good for coverage)
What method would be most desirable in this situation? This pretty much also applies to any other scenarios where a task is very repetitive.