https://github.com/danny02/do-not-mock-examples
https://github.com/danny02/do-not-mock-examples
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/danny02/do-not-mock-examples
- Owner: Danny02
- Created: 2022-09-30T00:17:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-23T08:24:56.000Z (over 3 years ago)
- Last Synced: 2025-11-12T11:32:16.012Z (8 months ago)
- Language: Java
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Test examples exposing Mocks as the root of all evil
Here you will find a collection of cases in which fakes result
in more stable tests then if mocks where used.
## Cases
### CQRS
This is a more involved case. You can find a service that writes
and reads customer data. The data is managed in a write and read
model, which is updated from the write model.
The case consist of two similar implementations, which only differ
in the implementation of persistent layer.
In this scenario the application started with the version which
used a delete flag (flag package). This was then refactored to
just delete data directly (direct packag).
The refactored version (direct) contains a bug in the service
code.
Tests with mocks do not detect this bug, as can be seen
by executing the tests.
### Logging
Shows the problems when mocking overloaded methods.
The difficulties mocking Slf4j are also shown.
### Mockery
A real world implementation and test, which does not test anything.