DEV Community

Discussion on: Are unit tests a waste of your time?

 
rossdrew profile image
Ross • Edited

Your example isn't clear but either it's...

A method which calls three others and assigns a value outside the unit which is just testing that value was set on a mock. The unit test is describing that the unit passed responsibility of assigning a value elsewhere. We just need to check the value is correct.

A method which calls three others and assigns an internal value which is a unit test that checks a unit has a certain value after x() is called. The unit test is describing that calling x() mutates the state of the unit.

A method which calls three others and returns a value which is a unit test to check the return value. The unit test is describing that a value is expected when this method is called.

In either of these you could run 1000 tests in a split second. You will never reach that kind of coverage on E2E and if you do it will cost you a hugely unreasonable time investment. All of these tests focus on aunit as a black box and therefore a What and not a How so not sure what your complaint on that front is.

It sounds like your E2Es are providing the best value because your units or your unit tests, likely both, are badly designed.