I have read several articles and posts on the subject but many contradict themselves and do not make it very clear and simply put a simple definition that does not explain the difference. I already know that there are 5 types of test doubles but the ones that are most similar are Mocks and Stubs.
I can't put any tag like #test
or #test-doubles
so I put the only one I found that refers to some test.
It is not easy to understand, much less explain, which is why there are so many sites that try to clarify this question. I will try to explain it to you as simply as possible, just as I interpret it (this is important, because not everyone interprets it the same way):
Mock : It is used to check the flow. Stub : Used to check functionality.
That is to say, I will use a Mock if I am interested in knowing that, by calling a certain function, it is, for example, executing the call to another, without caring (at least not too much) about the result.
Instead , I will use a Stub if I am interested in knowing that, calling a certain function, it returns a certain result, without caring (at least for the moment or too much) if it has had to make calls to other functions to achieve it.
Taking into account that it seems that you know enough about testing, I hope that this clarification will be useful to you. Cheers!