Recall & Review
beginner
What is Mockito used for in testing?
Mockito is a Java library used to create mock objects for unit testing. It helps simulate behavior of real objects to test code in isolation.
Click to reveal answer
beginner
How do you add Mockito dependency using Maven?
Add this to your
pom.xml inside <dependencies>:<br><dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>5.4.0</version> <scope>test</scope> </dependency>
Click to reveal answer
beginner
How to add Mockito dependency using Gradle?
Add this line to your
build.gradle inside dependencies:<br>testImplementation 'org.mockito:mockito-core:5.4.0'
Click to reveal answer
intermediate
What JUnit version is commonly used with Mockito 5+?
JUnit 5 (JUnit Jupiter) is commonly used with Mockito 5 and above for modern testing features and better integration.
Click to reveal answer
intermediate
What is the purpose of the
@ExtendWith(MockitoExtension.class) annotation?It tells JUnit 5 to enable Mockito support, so you can use annotations like
@Mock and @InjectMocks without manual setup.Click to reveal answer
Which Maven scope should you use for Mockito dependency?
✗ Incorrect
Mockito is used only during testing, so the 'test' scope ensures it is not included in production builds.
Which Gradle configuration is correct for adding Mockito?
✗ Incorrect
Mockito is a test library, so it should be added with 'testImplementation' to be available only during tests.
What annotation enables Mockito support in JUnit 5?
✗ Incorrect
In JUnit 5, '@ExtendWith(MockitoExtension.class)' activates Mockito features like mocks and injections.
Which version of Mockito is recommended for use with JUnit 5?
✗ Incorrect
Mockito 5.x is the latest major version with improved support for JUnit 5.
Why do we use mock objects in unit testing?
✗ Incorrect
Mocks simulate dependencies so tests focus only on the code being tested, making tests faster and more reliable.
Explain how to set up Mockito dependency in a Java project using Maven or Gradle.
Think about where to add dependencies in build files and the scope for test libraries.
You got /3 concepts.
Describe the role of the @ExtendWith(MockitoExtension.class) annotation in JUnit 5 tests.
Consider how JUnit 5 integrates with Mockito to simplify test setup.
You got /3 concepts.