• Tutorials
  • Courses
  • Tracks

Advance Java Quiz Day 82

Last Updated :
Discuss
Comments

Question 1

What is the main purpose of Mockito in Java testing?

  • To connect to real databases during tests

  • To create mock objects for unit testing

  • To generate test reports

  • To perform load testing

Question 2

Which annotation in Mockito is used to create and inject mock objects automatically?

  • @Mock

  • @InjectMocks

  • @MockBean

  • Both @Mock and @InjectMocks

Question 3

Which Mockito method is used to define the behavior of a mock object?

  • mockBehavior()

  • when(...).thenReturn(...)

  • given(...).willReturn(...)

  • Both B and C

Question 4

In a Mockito + JUnit test, what is the purpose of @ExtendWith(MockitoExtension.class)?

  • To enable database mocking

  • To initialize Mockito annotations

  • To extend test execution time

  • To enable HTTP mocking

Question 5

Which statement is TRUE about Mockito and JUnit integration?

  • Mockito replaces JUnit entirely

  • Mockito is used for mocking dependencies, and JUnit runs the tests

  • JUnit mocks dependencies, and Mockito runs the tests

  • Mockito can only be used with JUnit 4

Question 6

Which Mockito method is used to verify that a mocked method was called a specific number of times?

  • check()

  • assertCalled()

  • verify()

  • validate()

Question 7

In Mockito, which argument matcher is used to match any value of a given type?

  • any()

  • eq()

  • isA()

  • All of the above

There are 7 questions to complete.

Take a part in the ongoing discussion