In Spring Boot, how do you customize the behavior of a mocked object for specific arguments using Mockito?
- By using the @InjectMocks annotation
- By using the @Mockito annotation
- By using the @Spy annotation
- By using the when(...).thenReturn(...) syntax
To customize the behavior of a mocked object for specific arguments using Mockito in Spring Boot, you can use the when(...).thenReturn(...) syntax. This allows you to specify the return value of a method call based on the input arguments. The other annotations mentioned are used for different purposes in Mockito.
Loading...
Related Quiz
- In a microservices architecture using Spring Cloud, _____ is a crucial aspect ensuring the autonomy and independence of individual microservices.
- The order in which auto-configurations are applied in Spring Boot can be influenced using the _____ property.
- What considerations should be taken into account when determining the Time-To-Live (TTL) of a cache in a Spring Boot application?
- How can you specify a default value for a request parameter in a Spring Boot controller method?
- You notice that a Spring Boot application is experiencing high latency. How would you go about identifying and resolving the performance bottlenecks in the application?