From ffa4e67acb5c40f645cc787d583da0959f350f1d Mon Sep 17 00:00:00 2001 From: Schmoho Date: Tue, 23 Aug 2022 12:46:40 +0200 Subject: [PATCH] sparser logging + fix container testing setup for gradle runs --- build.gradle | 14 +++++++++++ .../ucsd/sbrg/bigg/annotation/BiGGDBTest.java | 23 +++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 3419de07..fcb3ec8e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,6 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + plugins { id "java" id "application" @@ -49,6 +52,17 @@ test { } } +tasks.withType(Test) { + testLogging { + events TestLogEvent.FAILED + exceptionFormat TestExceptionFormat.FULL + showCauses true + showExceptions true + showStackTraces true + showStandardStreams false + } +} + repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } diff --git a/src/test/java/edu/ucsd/sbrg/bigg/annotation/BiGGDBTest.java b/src/test/java/edu/ucsd/sbrg/bigg/annotation/BiGGDBTest.java index f7967e26..c2dc23b6 100644 --- a/src/test/java/edu/ucsd/sbrg/bigg/annotation/BiGGDBTest.java +++ b/src/test/java/edu/ucsd/sbrg/bigg/annotation/BiGGDBTest.java @@ -1,10 +1,7 @@ package edu.ucsd.sbrg.bigg.annotation; import edu.ucsd.sbrg.db.BiGGDB; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.testcontainers.containers.GenericContainer; -import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; @@ -13,22 +10,14 @@ @Testcontainers public abstract class BiGGDBTest { - - @BeforeEach - public void setup() { - BiGGDB.init(bigg.getHost(), bigg.getFirstMappedPort().toString(), "postgres", "postgres", "bigg"); - } - - @AfterEach - public void cleanUp() { - if (BiGGDB.inUse()) - BiGGDB.close(); - } - - @Container - public GenericContainer bigg = new GenericContainer(DockerImageName.parse("preloaded_bigg:latest")) + static final GenericContainer bigg = new GenericContainer(DockerImageName.parse("preloaded_bigg:latest")) .withExposedPorts(5432) .withEnv("POSTGRES_PASSWORD", "postgres") .withStartupTimeout(Duration.ofMinutes(5)); + static { + bigg.start(); + BiGGDB.init(bigg.getHost(), bigg.getFirstMappedPort().toString(), "postgres", "postgres", "bigg"); + } + }