Skip to content

Commit 14f90c8

Browse files
yasin3061maibin
authored andcommitted
BAEL-905 Improvements in spring boot testing (eugenp#1783)
* BAEL-88 Testing in Spring Boot * BAEL-88 Integration tests fixed. * BAEL-905 Improvement task for spring boot testing * BAEL-905 Improvement task for spring boot testing
1 parent 267b550 commit 14f90c8

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRestControllerIntegrationTest.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
import org.junit.Test;
2020
import org.junit.runner.RunWith;
2121
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
2223
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
2324
import org.springframework.boot.test.context.SpringBootTest;
2425
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2526
import org.springframework.http.MediaType;
26-
import org.springframework.test.context.TestPropertySource;
2727
import org.springframework.test.context.junit4.SpringRunner;
2828
import org.springframework.test.web.servlet.MockMvc;
2929

3030
@RunWith(SpringRunner.class)
3131
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = DemoApplication.class)
3232
@AutoConfigureMockMvc
33-
@TestPropertySource(locations = "classpath:application-integrationtest.properties")
33+
// @TestPropertySource(locations = "classpath:application-integrationtest.properties")
34+
@AutoConfigureTestDatabase
3435
public class EmployeeRestControllerIntegrationTest {
3536

3637
@Autowired
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
spring.datasource.url = jdbc:h2:mem:test
2-
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.H2Dialect
1+
spring.datasource.url=jdbc:mysql://localhost:3306/employee_int_test
2+
spring.datasource.username=root
3+
spring.datasource.password=root
4+

0 commit comments

Comments
 (0)