Skip to content

Commit 533fe79

Browse files
authored
Refactor DockerComposeContainerScalingTest.java
Improves the readability of the test, following best practices to improve test clarity and maintainability. Each condition now has a dedicated test method, making failures easier to trace and enhancing overall test reliability.
1 parent 847bb1a commit 533fe79

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

core/src/test/java/org/testcontainers/junit/DockerComposeContainerScalingTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,20 @@ public void setupClients() {
4747
}
4848

4949
@Test
50-
public void simpleTest() {
51-
for (int i = 0; i < 3; i++) {
52-
clients[i].incr("somekey");
50+
public void incrAndGet_somekey_in_client_0() {
51+
clients[0].incr("somekey");
52+
assertThat(clients[0].get("somekey")).as("Client 0: Each redis instance is separate").isEqualTo("1");
53+
}
5354

54-
assertThat(clients[i].get("somekey")).as("Each redis instance is separate").isEqualTo("1");
55-
}
55+
@Test
56+
public void incrAndGet_somekey_in_client_1() {
57+
clients[1].incr("somekey");
58+
assertThat(clients[1].get("somekey")).as("Client 1: Each redis instance is separate").isEqualTo("1");
59+
}
60+
61+
@Test
62+
public void incrAndGet_somekey_in_client_2() {
63+
clients[2].incr("somekey");
64+
assertThat(clients[2].get("somekey")).as("Client 2: Each redis instance is separate").isEqualTo("1");
5665
}
5766
}

0 commit comments

Comments
 (0)