
Use Mockito with JUnit5
Authored by ANIL KUMAR
Computers
Professional Development

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
31 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Does Mockito work with JUnit 5?
a) Yes, Mockito is compatible with JUnit 5.
b) No, Mockito only works with JUnit 4.
c) Mockito can work with JUnit 5 but requires additional configuration.
d) Mockito is not designed to work with any unit testing frameworks.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can Mockito be used in JUnit 5?
a) By manually creating mock objects using Mockito.mock() method.
b) By annotating fields with @Mock and initializing using MockitoAnnotations.openMocks() method.
c) By applying the MockitoExtension and annotating fields with @Mock.
d) All of the above.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How to use Mockito with JUnit 5 in Spring Boot?
a) Annotate the class with @ExtendWith(MockitoExtension.class).
b) Use @InjectMocks to inject mock objects into the test class.
c) Mock the desired dependencies and change their method responses.
d) All of the above.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Is JUnit 5 compatible with Java?
a) Yes, JUnit 5 requires Java 8 or higher.
b) No, JUnit 5 only works with Java 7 or lower.
c) JUnit 5 is compatible with Java 11 or higher.
d) JUnit 5 supports all versions of Java.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between Mockito and JUnit 5?
a) JUnit 5 is a testing framework, while Mockito is a mocking framework.
b) JUnit 5 is used for writing and running tests, whereas Mockito is used for creating mock objects.
c) Mockito is specifically designed for unit testing, while JUnit 5 is a more general-purpose testing framework.
d) All of the above.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How to add Mockito to JUnit?
a) Create an interface for the desired functionality.
b) Implement a Java class and write test cases for it.
c) Use Mockito's verification methods to validate the results.
d) All of the above.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How to mock private methods using Mockito in JUnit 5?
a) Mockito has direct support for mocking private methods.
b) Change the access of private methods to protected or package-private for testing.
c) Refactor the code to avoid private and static methods.
d) Mocking private methods is not possible with Mockito.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?