26 Ağustos 2021 Perşembe

SpringBoot Test Sliced Test Anotasyonları

Test Slices Nedir?
Açıklaması şöyle. @SpringBootTest kullanmaktan çok daha iyi
Whenever your tests go beyond trivial unit testing and you include Spring Test features, you'll most likely start a customized Spring Context (e.g. @SpringBootTest@WebMvcTest@DataJpaTest).
Açıklaması şöyle.
Test Slices are a Spring Boot feature introduced in the 1.4. The idea is fairly simple, Spring will create a reduced application context for a specific slice of your app.

Also, the framework will take care of configuring the very minimum.

There are a sensible number of slices available out of the box in Spring Boot and we can create our own too:

- @JsonTest: Registers JSON relevant components
- @DataJpaTest: Registers JPA beans, including the ORM available
- @JdbcTest: Useful for raw JDBC tests, takes care of the data source and in memory DBs without ORM frills
- @DataMongoTest: Tries to provide an in-memory mongo testing setup
- @WebMvcTest: A mock MVC testing slice without the rest of the app

This particular feature if used wisely can help us build narrow tests without such a big penalty in terms of performance particularly for small/medium sized apps.
Bazı anotasyonlar şöyle
@DataLdapTest
@DataMongoTest
@DataNeo4jTest
@DataRedisTest

@JsonTest
@JooqTest


@RestClientTest
@WebFluxTest

Hiç yorum yok:

Yorum Gönder