Skip to content

Migrate test to JUnit5 #4139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f3e7988
Use junit5 for new test
ggivo Nov 20, 2024
996c5a1
Add Junit5 Conditions
ggivo Apr 3, 2025
951ec22
Refactor junit conditions to use AnnotationUtils
ggivo Apr 3, 2025
799fa38
Migrate commands.commandobjects tests
ggivo Apr 3, 2025
803ea20
Rebase
ggivo Apr 7, 2025
65b749d
Migrate collections tests
ggivo Apr 4, 2025
a8fc7f0
junit 5.13.0-M1 introduces support for parameterised Class tests
ggivo Apr 4, 2025
59d93ec
Migrate redis.clients.jedis to JUnit5
ggivo Apr 4, 2025
13214a7
clean up warnings
ggivo Apr 4, 2025
cb89c94
Migrate commands/unified tests
ggivo Apr 4, 2025
827f4a0
Delete EnabledOnCommandRule.java
ggivo Apr 4, 2025
7fb7188
migrate ExceptionsTest
ggivo Apr 4, 2025
d19868b
migrate csc tests
ggivo Apr 4, 2025
e013b16
migrate misc tests
ggivo Apr 4, 2025
480360a
migrate authentication tests
ggivo Apr 4, 2025
48539cd
migrate examples tests
ggivo Apr 4, 2025
7fc50fc
migrate mocked tests
ggivo Apr 4, 2025
6c43239
Migrate module tests
ggivo Apr 6, 2025
62b654c
Migrate parameters tests
ggivo Apr 6, 2025
5fa7e13
Migrate prefix tests
ggivo Apr 6, 2025
bd5ed3c
Migrate providers tests
ggivo Apr 6, 2025
7f395ab
Migrate scenariou & remaining tests
ggivo Apr 6, 2025
86b08e9
Migrate examples tests
ggivo Apr 6, 2025
625564b
Remove junit4 & junit-vintage
ggivo Apr 6, 2025
50b3ad8
Clean up
ggivo Apr 6, 2025
9f9e896
Use mockito-junit-jupiter:4.11.0 for java 1.8 compatibility
ggivo Apr 7, 2025
58d7766
Rebase
ggivo Apr 7, 2025
5ddfa12
Fix ACLJedisPoolTest, ACLJedisSentinelPoolTest tests
ggivo Apr 7, 2025
464a813
Fix ACLJedisSentinelPoolTest tests
ggivo Apr 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 31 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,21 @@
<resilience4j.version>1.7.1</resilience4j.version>
<jackson.version>2.18.3</jackson.version>
<maven.surefire.version>3.5.2</maven.surefire.version>
<junit.version>5.13.0-M1</junit.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -101,9 +114,24 @@

<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
15 changes: 9 additions & 6 deletions src/test/java/io/redis/examples/BitMapsExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// HIDE_START
package io.redis.examples;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.UnifiedJedis;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class BitMapsExample {

@Test
Expand All @@ -29,9 +32,9 @@ public void run() {
// STEP_END

// REMOVE_START
Assert.assertFalse(res1);
Assert.assertTrue(res2);
Assert.assertFalse(res3);
assertFalse(res1);
assertTrue(res2);
assertFalse(res3);
// REMOVE_END

// STEP_START bitcount
Expand All @@ -40,7 +43,7 @@ public void run() {
// STEP_END

// REMOVE_START
Assert.assertEquals(1, res4);
assertEquals(1, res4);
// REMOVE_END

// HIDE_START
Expand Down
13 changes: 7 additions & 6 deletions src/test/java/io/redis/examples/BitfieldExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// REMOVE_START
package io.redis.examples;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
// REMOVE_END

// HIDE_START
import redis.clients.jedis.UnifiedJedis;

import static org.junit.jupiter.api.Assertions.assertEquals;
// HIDE_END

// HIDE_START
Expand Down Expand Up @@ -40,10 +41,10 @@ public void run() {

// Tests for 'bf' step.
// REMOVE_START
Assert.assertEquals("[0]", res1.toString());
Assert.assertEquals("[950, 1]", res2.toString());
Assert.assertEquals("[1450, 2]", res3.toString());
Assert.assertEquals("[1450, 2]", res4.toString());
assertEquals("[0]", res1.toString());
assertEquals("[950, 1]", res2.toString());
assertEquals("[1450, 2]", res3.toString());
assertEquals("[1450, 2]", res4.toString());
// REMOVE_END

// HIDE_START
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/io/redis/examples/BloomFilterExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
package io.redis.examples;

import redis.clients.jedis.UnifiedJedis;
import org.junit.Test;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class BloomFilterExample {

@Test
Expand All @@ -24,7 +25,7 @@ public void run() {
System.out.println(res1); // >>> OK

// REMOVE_START
Assert.assertEquals("OK", res1);
assertEquals("OK", res1);
// REMOVE_END

boolean res2 = jedis.bfAdd("bikes:models", "Smoky Mountain Striker");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/redis/examples/CMSExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//REMOVE_START
import redis.clients.jedis.UnifiedJedis;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.List;
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/io/redis/examples/CmdsCnxmgmtExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// REMOVE_START
package io.redis.examples;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
// REMOVE_END

import redis.clients.jedis.Jedis;

import static org.junit.jupiter.api.Assertions.assertEquals;

// HIDE_START
public class CmdsCnxmgmtExample {
@Test
Expand All @@ -24,7 +25,7 @@ public void run() {
String authResult1 = jedis.auth("default", "temp_pass");
System.out.println(authResult1); // >>> OK
// REMOVE_START
Assert.assertEquals("OK", authResult1);
assertEquals("OK", authResult1);
jedis.configSet("requirepass", "");
// REMOVE_END
// STEP_END
Expand All @@ -38,7 +39,7 @@ public void run() {
String authResult2 = jedis.auth("test-user", "strong_password");
System.out.println(authResult2); // >>> OK
// REMOVE_START
Assert.assertEquals("OK", authResult2);
assertEquals("OK", authResult2);
jedis.aclDelUser("test-user");
// REMOVE_END
// STEP_END
Expand Down
35 changes: 18 additions & 17 deletions src/test/java/io/redis/examples/CmdsGenericExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// REMOVE_START
package io.redis.examples;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
// REMOVE_END

// HIDE_START
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.args.ExpiryOption;

import static org.junit.jupiter.api.Assertions.assertEquals;
// HIDE_END

// HIDE_START
Expand Down Expand Up @@ -36,9 +37,9 @@ public void run() {

// Tests for 'del' step.
// REMOVE_START
Assert.assertEquals("OK", delResult1);
Assert.assertEquals("OK", delResult2);
Assert.assertEquals(2, delResult3);
assertEquals("OK", delResult1);
assertEquals("OK", delResult2);
assertEquals(2, delResult3);
// REMOVE_END


Expand Down Expand Up @@ -73,15 +74,15 @@ public void run() {

// Tests for 'expire' step.
// REMOVE_START
Assert.assertEquals("OK", expireResult1);
Assert.assertEquals(1, expireResult2);
Assert.assertEquals(10, expireResult3);
Assert.assertEquals("OK", expireResult4);
Assert.assertEquals(-1, expireResult5);
Assert.assertEquals(0, expireResult6);
Assert.assertEquals(-1, expireResult7);
Assert.assertEquals(1, expireResult8);
Assert.assertEquals(10, expireResult9);
assertEquals("OK", expireResult1);
assertEquals(1, expireResult2);
assertEquals(10, expireResult3);
assertEquals("OK", expireResult4);
assertEquals(-1, expireResult5);
assertEquals(0, expireResult6);
assertEquals(-1, expireResult7);
assertEquals(1, expireResult8);
assertEquals(10, expireResult9);
jedis.del("mykey");
// REMOVE_END

Expand All @@ -99,9 +100,9 @@ public void run() {

// Tests for 'ttl' step.
// REMOVE_START
Assert.assertEquals("OK", ttlResult1);
Assert.assertEquals(1, ttlResult2);
Assert.assertEquals(10, ttlResult3);
assertEquals("OK", ttlResult1);
assertEquals(1, ttlResult2);
assertEquals(10, ttlResult3);
jedis.del("mykey");
// REMOVE_END

Expand Down
37 changes: 19 additions & 18 deletions src/test/java/io/redis/examples/CmdsHashExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// REMOVE_START
package io.redis.examples;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
// REMOVE_END

import java.util.HashMap;
Expand All @@ -16,6 +15,8 @@
// HIDE_END

import static java.util.stream.Collectors.toList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

// HIDE_START
public class CmdsHashExample {
Expand Down Expand Up @@ -45,9 +46,9 @@ public void run() {
// STEP_END
// REMOVE_START
// Tests for 'hget' step.
Assert.assertEquals(1, hGetResult1);
Assert.assertEquals("foo", hGetResult2);
Assert.assertNull(hGetResult3);
assertEquals(1, hGetResult1);
assertEquals("foo", hGetResult2);
assertNull(hGetResult3);
jedis.del("myhash");
// REMOVE_END

Expand All @@ -70,8 +71,8 @@ public void run() {
// STEP_END
// REMOVE_START
// Tests for 'hgetall' step.
Assert.assertEquals(2, hGetAllResult1);
Assert.assertEquals("[field1=Hello, field2=World]",
assertEquals(2, hGetAllResult1);
assertEquals("[field1=Hello, field2=World]",
hGetAllResult2.entrySet().stream()
.sorted((s1, s2)-> s1.getKey().compareTo(s2.getKey()))
.collect(toList())
Expand Down Expand Up @@ -112,15 +113,15 @@ public void run() {
// STEP_END
// REMOVE_START
// Tests for 'hset' step.
Assert.assertEquals(1, hSetResult1);
Assert.assertEquals("Hello", hSetResult2);
Assert.assertEquals(2, hSetResult3);
Assert.assertEquals("Hi", hSetResult4);
Assert.assertEquals("World", hSetResult5);
Assert.assertEquals(3, hSetResult6.size());
Assert.assertEquals("Hello", hSetResult6.get("field1"));
Assert.assertEquals("Hi", hSetResult6.get("field2"));
Assert.assertEquals("World", hSetResult6.get("field3"));
assertEquals(1, hSetResult1);
assertEquals("Hello", hSetResult2);
assertEquals(2, hSetResult3);
assertEquals("Hi", hSetResult4);
assertEquals("World", hSetResult5);
assertEquals(3, hSetResult6.size());
assertEquals("Hello", hSetResult6.get("field1"));
assertEquals("Hi", hSetResult6.get("field2"));
assertEquals("World", hSetResult6.get("field3"));
jedis.del("myhash");
// REMOVE_END

Expand All @@ -139,8 +140,8 @@ public void run() {
// STEP_END
// REMOVE_START
// Tests for 'hvals' step.
Assert.assertEquals(2, hValsResult1);
Assert.assertEquals("[Hello, World]", hValsResult2.toString());
assertEquals(2, hValsResult1);
assertEquals("[Hello, World]", hValsResult2.toString());
jedis.del("myhash");
// REMOVE_END

Expand Down
Loading
Loading