Loading

Quipoin Menu

Learn • Practice • Grow

spring / Unit Testing with JUnit and Mockito
mcq
Direction: Choose the correct option

Q1.

What is JUnit?
A. A unit testing framework for Java
B. A mocking framework
C. An integration testing tool
D. None
Direction: Choose the correct option

Q2.

What is Mockito?
A. A mocking framework to create test doubles
B. A testing framework
C. An assertion library
D. None
Direction: Choose the correct option

Q3.

Which annotation is used to create a mock object in Mockito?
A. @Mock
B. @MockBean
C. @InjectMocks
D. @Spy
Direction: Choose the correct option

Q4.

What does @InjectMocks do?
A. Creates an instance and injects mocks into it
B. Injects dependencies
C. Creates a mock
D. None
Direction: Choose the correct option

Q5.

How do you verify a method was called on a mock?
A. Mockito.verify(mock).method()
B. assertTrue(mock.called)
C. mock.verify()
D. None
Direction: Choose the correct option

Q6.

What is the purpose of when().thenReturn() in Mockito?
A. To stub a method to return a specific value
B. To verify a call
C. To throw an exception
D. None
Direction: Choose the correct option

Q7.

Which annotation is used for Spring Boot tests?
A. @SpringBootTest
B. @WebMvcTest
C. @DataJpaTest
D. All of the above
Direction: Choose the correct option

Q8.

What does @WebMvcTest do?
A. Loads only web layer components for testing controllers
B. Loads full context
C. Tests MVC
D. None
Direction: Choose the correct option

Q9.

How do you mock a bean in a Spring test?
A. @MockBean
B. @Mock
C. @MockitoBean
D. @MockService
Direction: Choose the correct option

Q10.

What is the use of @Test annotation?
A. Marks a method as a test method
B. Configures test
C. Enables test
D. None