3 ms·
> focusing on unit tests is, in most cases, a complete waste of time. Someone is pretty inexperienced by making that claim. Unit tests help to isolate the exp
by monksy 6y ago
> focusing on unit tests is, in most cases, a complete waste of time.
Someone is pretty inexperienced by making that claim. Unit tests help to isolate the expectations and verification to very small levels.
> While these changes may seem as an improvement to some, it’s important to point out that the interfaces we’ve defined serve no practical purpose other than making unit testing possible.
No it simplified the responsibility of the class. It also simplified your tests as well. Now you don't have to have tests that test many different scenarios.
> Note that although ILocationProvider exposes two different methods, from the contract perspective we have no way of knowing which one actually gets called.
Tests don't verify how you use or call other classes/methods. You can do verification if you want via mocks.
> Unit tests have a limited purpose
Yes, as does integration tests, functional tests, system tests. Etc. You shouldn't be trying to do unit level testing via an integration test.
> For example, does it make sense to unit test a method that calculates solar times using a long and complicated mathematical algorithm? Most likely, yes.
It does if you want to verify that the functionality is setting up the request correctly.
> Does it make sense to unit test a method that sends a request to a REST API to get geographical coordinates? Most likely, not.
That's not a unit test. That's an integration test(if you use a mock) or a functional test if you want to end a live end point.
> Unit tests lead to more complicated design
It highlights that the original design was complicated or the methods had side effects (which you should avoid). In his own example he seperated the resources from the functionality.
> Unit tests are expensive
No they're not. Mocks do not belong in a unit test. That's for integration tests. If you have them there you have issues. They're cheap to write and quick to run.
> Unit tests rely on implementation details
It's all about how you write you code, if you're trying to lump everything together, that's what you get.
> Unit tests don’t exercise user behavior
Correct, unit tests don't. Functional/feature or above do.
I stopped reading after this. It feels like the guy is just trying to argue that he doesn't like testing.