Skip to content

Commit

Permalink
Updated Verifyica version
Browse files Browse the repository at this point in the history
Signed-off-by: dhoard <[email protected]>
  • Loading branch information
dhoard committed Oct 10, 2024
1 parent 8994941 commit e7d47d9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion integration_test_suite/integration_tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<verifyica.version>0.3.0</verifyica.version>
<verifyica.version>0.4.0</verifyica.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
import io.prometheus.jmx.test.support.http.HttpResponseAssertions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.stream.Stream;
import org.testcontainers.containers.Network;
import org.verifyica.api.ArgumentContext;
import org.verifyica.api.ClassContext;
import org.verifyica.api.Trap;
import org.verifyica.api.Verifyica;

public abstract class AbstractExporterTest
Expand All @@ -45,7 +47,7 @@ public abstract class AbstractExporterTest
*
* @return the Stream of test environments
*/
@Verifyica.ArgumentSupplier
@Verifyica.ArgumentSupplier(parallelism = 4)
public static Stream<ExporterTestEnvironment> arguments() {
Collection<ExporterTestEnvironment> collection = new ArrayList<>();

Expand Down Expand Up @@ -141,22 +143,43 @@ protected void testMetricsPrometheusProtobufFormat(ArgumentContext argumentConte
}

@Verifyica.AfterAll
public void afterAll(ArgumentContext argumentContext) {
Optional.ofNullable(argumentContext.testArgument(ExporterTestEnvironment.class))
.ifPresent(
exporterTestEnvironmentArgument ->
exporterTestEnvironmentArgument.payload().destroy());
public void afterAll(ArgumentContext argumentContext) throws Throwable {
List<Trap> traps = new ArrayList<>();

traps.add(
new Trap(
() ->
Optional.ofNullable(
argumentContext.testArgument(
ExporterTestEnvironment.class))
.ifPresent(
exporterTestEnvironmentArgument ->
exporterTestEnvironmentArgument
.payload()
.destroy())));

// Close the network if it was created at the test argument scope
Optional.ofNullable(argumentContext.map().removeAs(NETWORK, Network.class))
.ifPresent(Network::close);
traps.add(
new Trap(
() ->
Optional.ofNullable(
argumentContext
.map()
.removeAs(NETWORK, Network.class))
.ifPresent(Network::close)));

Trap.assertEmpty(traps);
}

@Verifyica.Conclude
public static void conclude(ClassContext classContext) {
public static void conclude(ClassContext classContext) throws Throwable {
// Close the network if it was created at the test class scope
Optional.ofNullable(classContext.map().removeAs(NETWORK, Network.class))
.ifPresent(Network::close);
new Trap(
() ->
Optional.ofNullable(
classContext.map().removeAs(NETWORK, Network.class))
.ifPresent(Network::close))
.assertEmpty();
}

@Override
Expand Down

0 comments on commit e7d47d9

Please sign in to comment.