• Tutorials
  • Courses
  • Tracks

Advance Java Quiz Day 80

Last Updated :
Discuss
Comments

Question 1

Which annotation is used to enable Spring Boot testing with full application context?

  • @SpringTest

  • @SpringBootTest

  • @EnableTest

  • @BootTest

Question 2

What does @SpringBootTest do by default?

  • Starts the full Spring ApplicationContext for testing

  • Only tests controller methods without loading the context

  • Disables the application context for faster tests

  • Runs tests only for repository layers

Question 3

Which Spring Boot test annotation is typically used for testing only the web layer?

  • @SpringBootTest

  • @RestTest

  • @WebMvcTest

  • @WebTest

Question 4

What is the purpose of MockMVC in Spring Boot testing?

  • To mock database connections

  • To simulate HTTP requests and test controllers without starting a server

  • To mock microservice communication

  • To validate Spring Boot configurations

Question 5

Which method of MockMvc is used to send a GET request in tests?

  • mockGet()

  • sendGetRequest()

  • executeGet()

  • perform(get(...))

Question 6

In a Spring Boot test, which annotation is used to inject a MockMvc instance?

  • @Autowired

  • @InjectMockMvc

  • @EnableMockMvc

  • @MockMvcBean

Question 7

Which dependency is required to use MockMvc in a Spring Boot project?

  • spring-boot-starter-data-jpa

  • spring-boot-starter-test

  • spring-boot-starter-webflux

  • spring-boot-test-mockmvc

Question 8

In MockMvc, which method is used to validate HTTP status codes?

  • andExpect(status().isOk())

  • assertStatusOk()

  • verifyStatus(200)

  • expectStatusOk()

Question 9

Which statement about MockMvc is TRUE?

  • It requires a running server to send HTTP requests

  • It is used for unit testing without involving the web layer

  • It allows testing controllers without starting a full HTTP server

  • It can only be used with @SpringBootTest

There are 9 questions to complete.

Take a part in the ongoing discussion