What (not) to unit test?

For your addTwo example, I wouldn’t test it. Now in general, I am very aware of how even supposedly simple calculations can fail (off by one, sign error, etc). But the function addTwo is so trivial, that I fully understand it by reading the code. There is nothing that I’m unsure about. You don’t need to test constants, and I think similarly you don’t need to test code that feels trivial.

So my current approach is to work on the types first and foremost (as others have also mentioned). Then, if there are cases where I’m not entirely sure whether something works, I will write a test for that.

1 Like