Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What is the purpose of mocks in unit testing?
Think about what you do when you don't want to use real components.
What annotation do you use to inject mocks in a class with Mockito?
Remember the prefix ‘@’ which is common in annotations.
What does the @InjectMocks annotation do?
Think about what the annotation helps with during testing.
True or False:Mocks can also be used for testing private methods.
Recall the purpose of unit testing.
Create a unit test using Mockito that injects mocks into a class with multiple dependencies. Include verification for the expected behavior.
Set up @InjectMocks for `UserService`, use when() for mock behaviors, and verify() to check interactions.
Explain how injecting mocks contributes to the TDD process and write a test case reflecting this process.
Consider the classic TDD cycle: Red, Green, Refactor.
4 more questions in this section. Enroll free to practise them all.
Enroll free