This is an adaptation of the original kata available at github.com/aleixmorgadas/mocks-fakes-spies-and-stubs-kata
- Blog post The Little Mocker by Robert C. Martin a.k.a. Uncle Bob
- Clone the repository
git clone https://stash.murex.com/scm/xps/mocks-fakes-spies-and-stubs-kata.git
- Check that all tests are green
./gradlew test
kata.domain.film
: Test-Doubles examples made with Mockito and hand-made examples.kata.domain.user
: Support domain to represent the UserIdkata.domain.rate
: Actual katakata.support
: InMemoryRepositories
Check the tests in kata.domain.rate.
You will see RateServiceTest_Fake and RateServiceTest_Mock_Stub_Spy. Implement each Test following the named pattern.
Info: Remember that using two different Test Double types in the same test is allowed.
For each of the following cases, observe which tests turn red and which remain green.
- Introduce some bugs
- Refactor by adding RateRepository.save(rate)
- Refactor by adding RateRepository.findByUser(userId) for optimisation
- Decreased the notification threshold by one
In RateService
test setups, use FilmRepositoryInMemory
instead of mocking FilmService
.
What do you observe?
Fill a table listing the pros, cons and fixes for each type of Test Double
Test Double Family | Pros | Cons | Fixes |
---|---|---|---|
Mocks, Spies, Stubs | |||
Fakes |
You can fill it from here