How can you inject mock beans into the Spring Application Context when writing a test in Spring Boot?
- @Autowired
- @BeanInject
- @InjectMocks
- @MockBean
In Spring Boot testing, you can use the @MockBean annotation to inject mock beans into the Spring Application Context. This is commonly used to replace real components with mock versions for testing.
Loading...
Related Quiz
- Which of the following is true about the deleteById method of a JpaRepository?
- To enable global method security in Spring Security, the _____ attribute should be set to true in the @EnableGlobalMethodSecurity annotation.
- How can you configure property sources in a specific order in Spring Boot for resolving properties?
- When performing tests with @DataJpaTest, it is important to ensure that the _____ is correctly configured.
- How can you handle exceptions globally across multiple controllers in a Spring Boot application?