Is it possible to unit test a method like the following?
void AddNumbers() {
int i = 2+2;
}
In other words, a method with no side effects really. Or are methods like these skipped and not usually tested? I would assume that “i” would normally be made a class-level variable, but then this has its drawbacks (nothing very big though).
Thanks
There is no value to a method with neither side-effects nor primary effects, such as you’ve presented. Calling it – from test code or production code – would, well, have no effect. So there’s nothing to test, and no reason for the method.