25 ms·
What do you mean by “order” in the sentence “... the order of state vs. behavior validation ...”? State validation means checking a stub dependency of the SUT
by Benjammer 6y ago
What do you mean by “order” in the sentence “... the order of state vs. behavior validation ...”?
State validation means checking a stub dependency of the SUT to make sure it’s in the right state. Behavior validation means you check a mock dependency to make sure the right functions were called the right number of times, and in the right order.
A stub is just a thing you can substitute for the dependency that knows how to tell the test it’s state, and a mock is a substitute for the dependency that knows how to tell it’s behavior, like which functions are called and how many times.
In terms of them being the same thing, they are both types of Test Doubles, so they both fall into a higher level category of “a substitute for a dependency of the system under test (SUT)”. The difference is how they’re used.
- hyko 6y agoI guess in the example given you could also validate behaviour by using a Spy Warehouse (a capturing stub). The theoretical distinction with Mocks is that they contain their own assertions. The practical distinction (when using mocking frameworks) is often that they allow testing a SUT that depends on concrete classes, without subclassing them.