This commit is contained in:
+6
-6
@@ -1,6 +1,7 @@
|
||||
package com.baeldung.springbootinitialload.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -16,7 +17,8 @@ import com.baeldung.boot.repository.EmployeeRepository;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@Sql({"/employees_schema.sql", "/import_employees.sql"})
|
||||
@Sql(scripts = {"/employees_schema.sql", "/import_employees.sql"}, executionPhase = BEFORE_TEST_CLASS)
|
||||
@Sql(scripts = {"/delete_employees_data.sql"}, executionPhase = AFTER_TEST_CLASS)
|
||||
public class SpringBootInitialLoadIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
@@ -24,14 +26,12 @@ public class SpringBootInitialLoadIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testLoadDataForTestClass() {
|
||||
assertEquals(3, employeeRepository.findAll()
|
||||
.size());
|
||||
assertEquals(3, employeeRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Sql(scripts = {"/import_senior_employees.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = TransactionMode.ISOLATED))
|
||||
@Sql(scripts = {"/import_senior_employees.sql"}, executionPhase = BEFORE_TEST_METHOD ,config = @SqlConfig(encoding = "utf-8", transactionMode = TransactionMode.ISOLATED))
|
||||
public void testLoadDataForTestCase() {
|
||||
assertEquals(5, employeeRepository.findAll()
|
||||
.size());
|
||||
assertEquals(5, employeeRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
DROP TABLE EMPLOYEES;
|
||||
Reference in New Issue
Block a user