22 Mart 2023 Çarşamba

SpringData Flyway @FlywayTest Anotasyonu

Örnek
Şöyle yaparız
@SpringBootTest
@ActiveProfiles("test")
@AutoConfigureTestDatabase
@FlywayTest
public class MyIntegrationTests {
  // ...
}
Açıklaması şöyle
@SpringBootTest: This annotation is used to specify that this is a Spring Boot integration test. It loads the complete application context and can be used to test the full functionality of the application.
@ActiveProfiles("test"): This annotation is used to specify that the "test" profile should be activated for this test class. This is useful if you have different profiles for different environments and want to use a specific profile for testing.
@AutoConfigureTestDatabase: This annotation is used to automatically configure a test database for the tests. By default, Spring Boot will configure an in-memory database, but you can also use a real database by specifying the @TestPropertySource annotation with the appropriate properties.
@FlywayTest: This annotation is used to automatically run Flyway migrations before each test method. This will ensure that the database schema is up-to-date and ready for testing. Additionally, it will clean the database by dropping all database objects and running the migrations from scratch.



Hiç yorum yok:

Yorum Gönder