4 ms·
I generally assume that production code will change in the future. Thus if the tests you write today do not guide those changes to not break other existing func
by bluGill 3y ago
I generally assume that production code will change in the future. Thus if the tests you write today do not guide those changes to not break other existing functionality since they so constrain your implementation that those tests will need to be deleted then the tests are not valuable.
I've seen code where every dependency was mocked and all tests ended up being the implementation calls some function with some arguments. Most of the functions can be called many different ways to get the same answers, but the tests forced a specific number.
- eitland 3y agoIt is easy to do mocks wrong. Here is however an example of how one does it right. Say you have a system that accepts input, does something with it and stores it to some storage. You don't want to touch actual storage in the build pipeline. Then you mock in testing out the storage. Everything can still be tested: - the validation of incoming stuff isn't affected at all - the transformations aren't affected - the only difference is your tests now read the output back from a memory location instead of from a permanent storage somewhere