DEV Community


Discussion on: A Series of My Unfortunate Mistakes (When Writing Tests)

tyrrrz profile image
Alexey Golub

I would argue that testing constructor that only assigns private initial value is unnecessary, seeing how you're testing methods that work with that value. After all, it doesn't matter what's going on inside a class if the output is correct.

briwa profile image
briwa Author

You have a point. I've mentioned in the article, maybe if the constructor function has some logic, it can be tested and asserted as well. But true that, in the example I've given, testing the constructor itself might not mean that much, just putting it there.