establish-testing-strategy #25

Merged
kasun merged 6 commits from establish-testing-strategy into main 2026-03-26 21:14:16 +01:00
3 changed files with 29 additions and 3 deletions
Showing only changes of commit 3f579799af - Show all commits
+1
View File
@@ -40,6 +40,7 @@ dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-validation-test") testImplementation("org.springframework.boot:spring-boot-starter-validation-test")
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test") testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.springframework.boot:spring-boot-starter-test")
} }
dependencyManagement { dependencyManagement {
@@ -1,13 +1,29 @@
package com.vaessl.app; package com.vaessl.app;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest @SpringBootTest
@ActiveProfiles("test")
class ApplicationTests { class ApplicationTests {
@Test @Autowired
void contextLoads() { private DataSource dataSource;
}
@Test
void connectionToTestDbWorks() throws SQLException {
try (Connection connection = dataSource.getConnection()) {
assertThat(connection.getMetaData().getURL()).contains("vaessl_test");
}
}
} }
@@ -0,0 +1,9 @@
spring:
datasource:
url : ${DB_TEST_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: ${PG_DRIVER_CLASS_NAME}
jpa:
hibernate:
ddl-auto: create-drop