Posts

@DataR2dbcTest - Testing Spring Data R2DBC components

Image
In this section, we will learn how to test  Data R2DBC components  with @DataR2dbcTest in the Spring Boot application. About  @DataR2dbcTest Instead of bootstrapping the entire application context for every test,  @DataR2dbcTest  allows us to initialize only the parts of the Application context that are relevant to Data R2DBC components tests. Regular @Component , @Service or @Controller beans are not scanned when using this annotation.  This approach not only speeds up the testing process but also ensures a focused and efficient testing environment.  This approach is also known as " slicing " the application context. The annotation supports the following attributes: excludeAutoConfiguration :  Auto-configuration exclusions that should be applied for this test. excludeFilters : beans that would ordinarily be added to the application context can be filtered using a set of exclude filters. includeFilters : beans that would otherwise be filtered and added to the application e

@SqlMergeMode - Spring Testing Annotation

Image
In this tutorial, we will learn about the  @SqlMergeMode  annotation, and at the end, we will see how the Spring Boot application can utilize the  @SqlMergeMode  annotation for testing. Therefore, read the post till the end. Before moving on, read our previous tutorial about  @Sql (click here) annotation .  Within the Spring testing context, SQL scripts and statements are executed against a database using the Spring  @Sql  annotation. About @SqlMergeMode The @SqlMergeMode  is a part of the  org.springframework.test.context.jdbc  package. It can be applied at the test class level or the test method level.  @Sql  declarations at the method level take precedence over those at the class level. But we can change this behavior by configuring  @SqlMergeMode . Two type of merge mode are there: MERGE OVERRIDE The OVERRIDE merge mode will be used by default. With the OVERRIDE mode, method-level @Sql declarations will effectively override class-level @Sql declarations.  The  method-level @SqlMer