Skip to main content

How to Connect, Test, and Automate Redis Using Katalon Studio

5 min read

So during my SDET internship, I realized something pretty fast: manually checking Redis keys is fine for quick exploratory testing, but it gets old real quick. Like, imagine running the same Redis commands over and over for regression tests. No thanks.

I figured there had to be a way to automate this. Turns out there is, meet Jedis, a Java client for Redis. Since Katalon Studio runs on Groovy (basically Java's cousin), they work together pretty well.

Here's how I set it up.

What you need first

Make sure you've got:

  1. Katalon Studio installed (duh)
  2. Gradle on your machine (installation guide here if you don't, or skip this if you want to install Jedis manually)

Step 1: Adding Jedis with Gradle

To use Jedis, we need to tell Gradle to grab the JAR files for us. Look for a build.gradle file in your project root. If it's not there, just create it.

Your default setup probably looks like this:

build.gradle
plugins {
id 'java'
id "com.katalon.gradle-plugin" version "0.1.2"
}

repositories {
mavenCentral()
}

dependencies {
// Dependencies go here
}

Now here's the thing—I tried three different methods to get this working, depending on what version issues you run into.

Method 1: The easy way (when it works)

This is the standard approach. If you're lucky, this just works.

Add Jedis to your dependencies:

build.gradle
dependencies {
implementation 'redis.clients:jedis:5.2.0'
}

Generate the Gradle wrapper (skip if you already have 'gradlew' file in your project directory):

gradle wrapper

Run the Katalon dependency task:

./gradlew katalonCopyDependencies
# Use gradlew.bat on Windows

If you see BUILD SUCCESS, check your Drivers folder for the new JARs and skip to Step 2. If it fails... welcome to Method 2 lol.

Method 2: When Gradle versions fight

Newer Gradle versions doesn't work well with the Katalon plugin (cmiiw). Here's the workaround:

Temporarily comment out the plugin:

build.gradle
plugins {
id 'java'
// id "com.katalon.gradle-plugin" version "0.1.2"
}

dependencies {
implementation 'redis.clients:jedis:5.2.0'
}

Force Gradle 7.6 (I found this version works well):

gradle wrapper --gradle-version 7.6

Uncomment the plugin line once the build succeeds, then run:

./gradlew katalonCopyDependencies
note

If katalonCopyDependencies still refuses to run, you might need a custom Gradle task. Honestly, just ask ChatGPT to generate one for you—it's pretty good at this stuff.

Method 3: Manual mode (last resort)

If Gradle is just being impossible, do it the old-fashioned way:

  1. Download the Jedis JAR and its dependencies (commons-pool, SLF4J) from Maven Repository
  2. In Katalon: Project > Settings > Library Management
  3. Click Add External Library and import the JARs
  4. Or just dump them in your project's /Drivers folder

Step 2: Make sure it actually worked

After one of those methods works, the JAR files should be in your Drivers folder. But we need to confirm Katalon can actually see them.

Open any test script and type import redis, then hit Ctrl + Space. You should see autocomplete suggestions like redis.clients.jedis.Jedis.

If that doesn't work...

Sometimes Katalon's cache gets stuck. Force a clean build:

  1. Close Katalon Studio
  2. Delete these from your project root:
    • bin folder
    • Libs folder
    • .classpath file
  3. Restart Katalon
info

Yeah, deleting build artifacts is kinda aggressive, but it usually fixes weird classpath issues.

Step 3: Testing it out

Let's actually prove this works. I made a simple test that connects to Redis, writes some data, waits 30 seconds (so you can verify in Redis Insight), then cleans up.

Test Cases/Redis_Connection_Test.groovy
import redis.clients.jedis.Jedis
import com.kms.katalon.core.util.KeywordUtil

// --- CONFIG ---
String redisHost = "your-host-here.com"
int redisPort = 12345
String redisPassword = "your-password-here"

Jedis jedis = new Jedis(redisHost, redisPort)
jedis.auth(redisPassword)

// 1. WRITE
String myKey = "jarvis:test_data"
String myValue = "It works!"
jedis.set(myKey, myValue)

// 2. PAUSE (so you can check Redis Insight if you want)
Thread.sleep(30000)

// 3. VERIFY
String valueFromRedis = jedis.get(myKey)
KeywordUtil.logInfo("Retrieved value: " + valueFromRedis)
assert valueFromRedis == myValue : "Data Mismatch"

// 4. CLEANUP
jedis.del(myKey)
jedis.close()

If everything's configured right, the test should pass and you'll see the data in Redis for 30 seconds. Pretty cool, right?

Redis Insight interface showing the newly created katalon_test key in the database browser
Redis Insight detail view confirming the value 'It works!' matches the test script data

Success! Redis Insight confirming the key jarvis:test_data was created with the correct value.

What you can do with this

You can do way more than just set and get. Check the Jedis docs or the Javadocs for the full list of commands.

Some ideas:

  • Verify cache invalidation
  • Test TTL (time-to-live) behavior
  • Check pub/sub message delivery
  • Validate data persistence
tip

Wrap common Redis operations in Custom Keywords so you can reuse them across test cases. Makes life way easier.

About this setup

Using Gradle in Katalon kinda feels like a workaround, ngl. Katalon "officially supports" it, but version conflicts happen (hence the three methods above). These are just the ways I got it working, there might be better approaches out there.

If you find a cleaner method, definitely lmk. Always down to learn better ways to do this stuff.

Anyway, hope this saves you from manually checking Redis keys a million times.

Happy testing!