diff options
author | Léo Geoffroy <leo.geoffroy@sonarsource.com> | 2024-02-20 16:30:20 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-02-21 20:02:34 +0000 |
commit | 4a921c76d47497ed1412a40e30e91e407eb8f37f (patch) | |
tree | 263bdfe9acdfa11e62997275f3fdf65680d37bda /server/sonar-db-core | |
parent | 55f91d45997bdd5fdf505d8d5769f3d75dd13180 (diff) | |
download | sonarqube-4a921c76d47497ed1412a40e30e91e407eb8f37f.tar.gz sonarqube-4a921c76d47497ed1412a40e30e91e407eb8f37f.zip |
SONAR-21643 Migrate db tests migration to Junit5
#
Diffstat (limited to 'server/sonar-db-core')
-rw-r--r-- | server/sonar-db-core/build.gradle | 4 | ||||
-rw-r--r-- | server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/server/sonar-db-core/build.gradle b/server/sonar-db-core/build.gradle index 3d32c75be42..c65d7834a21 100644 --- a/server/sonar-db-core/build.gradle +++ b/server/sonar-db-core/build.gradle @@ -26,12 +26,15 @@ dependencies { testImplementation 'com.microsoft.sqlserver:mssql-jdbc' testImplementation 'com.oracle.database.jdbc:ojdbc11' testImplementation 'com.tngtech.java:junit-dataprovider' + testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.mockito:mockito-core' testImplementation 'org.postgresql:postgresql' testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures' testImplementation project(':sonar-testing-harness') + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' testRuntimeOnly 'com.h2database:h2' testRuntimeOnly 'com.microsoft.sqlserver:mssql-jdbc' testRuntimeOnly 'com.oracle.database.jdbc:ojdbc11' @@ -43,6 +46,7 @@ dependencies { testFixturesApi 'org.apache.commons:commons-collections4' testFixturesImplementation 'com.oracle.database.jdbc:ojdbc11' + testFixturesImplementation 'org.junit.jupiter:junit-jupiter-api' testFixturesCompileOnly 'com.google.code.findbugs:jsr305' } diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java index e8d21132a01..75a29f2675e 100644 --- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java +++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java @@ -20,12 +20,15 @@ package org.sonar.db; import org.apache.commons.lang.StringUtils; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; /** * This class should be called using @Rule. * Data is truncated between each tests. The schema is created between each test. */ -public class CoreDbTester extends AbstractDbTester<CoreTestDb> { +public class CoreDbTester extends AbstractDbTester<CoreTestDb> implements BeforeEachCallback, AfterEachCallback { private CoreDbTester(CoreTestDb testDb) { super(testDb); @@ -55,4 +58,14 @@ public class CoreDbTester extends AbstractDbTester<CoreTestDb> { protected void after() { db.stop(); } + + @Override + public void afterEach(ExtensionContext extensionContext) throws Exception { + after(); + } + + @Override + public void beforeEach(ExtensionContext extensionContext) throws Exception { + before(); + } } |