QuizzesSpring Boot Testing with JUnit & Mockito: Beginner's Quiz
beginner
spring

Spring Boot Testing with JUnit & Mockito: Beginner's Quiz

Assess your understanding of basic testing concepts in Spring Boot using JUnit and Mockito.

15 minutes 15 questions Pass at 70%
Time Limit
15 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

15 questions on Spring Boot Testing with JUnit & Mockito: Beginner's Quiz. Work through them here, then start the quiz to answer them and see your score.

  1. 1.What is the primary purpose of using JUnit in Spring Boot applications?

    • ATo manage application dependencies
    • BTo deploy the application to production
    • CTo test the performance of the application
    • DTo write unit tests for application components
  2. 2.Which annotation is used to run a test with Spring support in JUnit?

    • A@RunWith(SpringRunner.class)
    • B@Test
    • C@MockBean
    • D@SpringBootTest
  3. 3.What is the role of @MockBean in a Spring Boot test?

    • ATo initialize database connections
    • BTo deploy the application
    • CTo create a mock object and add it to the Spring application context
    • DTo start the application context
  4. 4.Which annotation is used to indicate a method is a test method in JUnit?

    • A@Test
    • B@Before
    • C@Mock
    • D@After
  5. 5.What is Mockito primarily used for in testing?

    • ATo create database schemas
    • BTo mock dependencies and verify interactions
    • CTo manage application configurations
    • DTo deploy applications
  6. 6.How do you verify that a method was called once in Mockito?

    • Amock.methodCall()
    • BassertEquals(mock.methodCall())
    • CassertTrue(mock.methodCall())
    • Dverify(mock).methodCall()
  7. 7.Which Mockito method is used to specify the behavior of a mock?

    • Amock()
    • Bthen()
    • Cwhen()
    • Dspy()
  8. 8.What does @SpringBootTest do in a test class?

    • ADisables all tests
    • BRuns tests in parallel
    • CStarts the full application context
    • DMocks all beans in the context
  9. 9.Which of the following is NOT a feature of JUnit?

    • ADependency injection
    • BTest runners
    • CTest suites
    • DAssertions
  10. 10.In Mockito, what does the spy() method do?

    • AVerifies method calls
    • BInitializes the application context
    • CCreates a full mock
    • DCreates a partial mock
  11. 11.What is the purpose of @BeforeEach in JUnit 5?

    • ATo execute code once before all tests
    • BTo execute code before each test method
    • CTo execute code after each test method
    • DTo execute code once after all tests
  12. 12.Which annotation is used to ignore a test in JUnit?

    • A@Exclude
    • B@Disabled
    • C@Skip
    • D@Ignore
  13. 13.What is the purpose of the assertEquals method in JUnit?

    • ATo check if an object is an instance of a class
    • BTo check if a value is null
    • CTo check if a condition is true
    • DTo check if two values are equal
  14. 14.In a Spring Boot test, what is the purpose of @MockBean?

    • ATo replace a bean with a mock in the application context
    • BTo start the application server
    • CTo initialize the database
    • DTo deploy the application
  15. 15.Which of the following is a benefit of using unit tests?

    • AIncreased application size
    • BImproved code quality
    • CReduced server costs
    • DFaster deployment