Skip to content

Commit a07cd05

Browse files
committed
use @BeforeMethod instead of @BeforeTest
There is not a lot of places in the MicroProfile Fault Tolerance TCK that require executing some logic before each `@Test` method, but all of them use `@BeforeMethod`. The only exception is `CircuitBreakerMetricTest` and `CircuitBreakerTelemetryTest`, which use `@BeforeTest`. However, `@BeforeTest` in TestNG is nothing like `@BeforeTest` in JUnit -- in TestNG, it means before the `<test>` tag in `testng.xml`. This commit replaces the usage of `@BeforeTest` with `@BeforeMethod`. If the method was supposed to be called once before the test class, the proper annotation would be `@BeforeClass`, but this test class has exactly one `@Test` method, so it doesn't matter. If it had multiple, `@BeforeMethod` would actually be more appropriate, because it brings the circuit breaker into the initial (closed) state, regardless of the state it is currently in.
1 parent 1ec9280 commit a07cd05

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/metrics/CircuitBreakerMetricTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
4545
import org.jboss.shrinkwrap.api.spec.JavaArchive;
4646
import org.jboss.shrinkwrap.api.spec.WebArchive;
47-
import org.testng.annotations.BeforeTest;
47+
import org.testng.annotations.BeforeMethod;
4848
import org.testng.annotations.Test;
4949

5050
import jakarta.inject.Inject;
@@ -75,7 +75,7 @@ public static WebArchive deploy() {
7575
@Inject
7676
private CircuitBreakerMetricBean cbBean;
7777

78-
@BeforeTest
78+
@BeforeMethod
7979
public void closeTheCircuit() throws Exception {
8080

8181
// Condition is needed because BeforeTest runs on both client and server

tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/telemetryMetrics/CircuitBreakerTelemetryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import org.jboss.shrinkwrap.api.asset.StringAsset;
5454
import org.jboss.shrinkwrap.api.spec.JavaArchive;
5555
import org.jboss.shrinkwrap.api.spec.WebArchive;
56-
import org.testng.annotations.BeforeTest;
56+
import org.testng.annotations.BeforeMethod;
5757
import org.testng.annotations.Test;
5858

5959
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
@@ -90,7 +90,7 @@ public static WebArchive deploy() {
9090
@Inject
9191
private CircuitBreakerMetricBean cbBean;
9292

93-
@BeforeTest
93+
@BeforeMethod
9494
public void closeTheCircuit() throws Exception {
9595

9696
// Condition is needed because BeforeTest runs on both client and server

0 commit comments

Comments
 (0)