Search results for: junit

Dependency Injection is a design pattern that allows the separation of concerns in an application by removing the hard-coded dependencies between objects. In Dependency Injection, the objects are provided with their dependencies instead of having to hard-code them. This makes the application more flexible, maintainable, and easier to test. Spring Framework provides several ways to…

Read More Field-based Dependency Injection in Spring

Spring Framework is a popular Java-based framework that provides a comprehensive infrastructure for developing Java applications. The framework was initially released in 2002 by Rod Johnson, who was frustrated with the complexity of the existing Java EE (Enterprise Edition) platform. He wanted to create a simpler and more lightweight framework that would make it easier…

Read More Excel in Spring Framework: The Complete Guide

In this tutorial, you will learn about @SpringBootTest annotation. You will use this annotation to write Integration Tests for your Spring Boot application. @SpringBootTest annotation is used to create a Spring Application Context that will be used during the test. It will make Spring Framework scan your application classes and look for different annotations. Depending…

Read More @SpringBootTest Annotation Example

In this blog post, you will learn the difference between @SpringBootTest and @WebMvcTest annotations. The main difference between the @SpringBootTest and @WebMvcTest annotations lies in the application context that they create. The @SpringBootTest annotation starts the full application context, which includes all the beans required for the application to function. On the other hand, the…

Read More Difference Between @SpringBootTest and @WebMvcTest

In this blog post, you will learn a couple of ways you can disable Spring Security Configuration for your @WebMvcTest. Disable Security Filters for @AutoConfigureMockMvc One of the ways you can disable Spring Security filters in your tests, is to use the @AutoConfigureMockMvc annotation. @AutoConfigureMockMvc annotation can be applied to a test class to enable…

Read More Disable Spring Security Configuration for @WebMvcTest

You will use @MockBean annotation to create and automatically add mocks to Spring ApplicationContext. In this tutorial, we will look at different ways you can use @MockBean annotation to create mocks. If you are testing your application with JUnit and Mockito, then there are many other useful tutorials you will find on the Testing Java Code…

Read More @MockBean Annotation Example