Creating a Mock
Verify
- Once created, a mock will remember its interactions which we can verify later
- We can verify the value of an interaction and the amount of times it was done
- Asserts check returned values where verify checks if an interaction actually happened
- We can also verify interactions in order
Stubbing
- Return the hard coded value we passed in
- The method will always return the stubbed value if called
Argument Captor
- Captures the value that is passed in
- Then we call verify and ask what was passed in
Spying
- You can create spies, where when you use the spy, the real methods are called unless they were stubbed.
- Avoid use since there are a ton of gotchas here.