Description
I felt the article was missing the difference between functions you wrote
(can test) and functions from 3rd party libraries (should not test, let the maintainers of that library test).
Is this a meaningful difference that can help readers infer the right course of action for the 5 permutations of {incoming,self,outgoing} x {Query, Command}?
The part of the article on API was confusing too.
The article introduced the difference between Query and Command as
Queries — Returns something but changes nothing
Commands — Returns nothing but changes something
Then under "Outgoing Command Messages" section says
A simple out-of-the-box way is to directly test the side effect i.e. read from the database or GET request from the API.
I was expecting these 2 side effects to be queries, not commands since they return something and change nothing.
Why are they under Outgoing Command Messages instead of Outgoing Query Messages?
The argument given to not test Outgoing Query is because it was already tested.
But this assumes we control the Wheel class. If the outgoing query was 3rd party code like requests.get
, we should test the returned value anyway right?
That's why I raised this issue.
It was also not clear whether we are using mocks because they are command messages, or because they are 3rd party code that we can't change, or because they are slow.
Mocks can both return a fixed state with return_value
and assert behaviour of method calls. In this article only the method calling behaviour aspect of mocks were used.