Running JUnit4 in Katalon Studio


I have made a demo project and published it on GitHub:

# Background

I am going to develop a custom Keyword in a Katalon Studio project. See a post in the Katalon forum for the background story. My custom keyword is expected to be fairly large, complicated, and therefore bug-prone. So I want to execute thorough unit-testing on my Groovy classes and methods with JUnit4 in Katalon Studio.

I was aware that the Katalon Studio’s distributed zip file contains plugins/org.junit_4.12.0.jar. I tried a test case of single line:

import org.junit.runner.JUnitCore

This worked! I mean, import statement succeeded, no error emitted. I realized that the JUnit classes are available in the Katalon Studio’s Java VM.

OK, all I need to know is where to locate test classes, how to activate the junit-test-runner, and how to report the test result. I have done an experiment. I believe I have got a success.


How to write Katalon Studio tests with IntelliJ IDEA and other IDEs
How to write Katalon Studio tests with IntelliJ IDEA and other IDEs

thanks a lot for your great work !!!


I have made a slight modification to the demo project.

Previously, the print “message” from test cases under JUnit did not appear in the Katalon Studio’s log. It was very inconvenient.

In the revised sample project, messages printed into System.out by test cases under JUnit is redirected to Katalon Studio’s log.


This is awesome. All Katalon Studio projects are essentially Eclipse projects so the trick is to init the project in Katalon Studio and then using Eclipse for running JUnit. I’ll add detailed steps soon.


I am glad to find people interested in idea of running JUnit in Katalon Studio.

What are you going to do?


I hope the last section of this tutorial would help


I have updated my demo project tagged as 1.0:

I introduced a custom keyword class com.kazurayam.ksbackyard.junit.JUnitCustomKeywords. This class provides a keyword method runWithJUnitRunner(Class clazz). Your test cases in Katalon Studio can call this custom keyword which runs your JUnit-based tests. Your JUnit-based tests are backed by the Katalon Studio runtime environment, so that it can interact with external Web sites via WebDriver. You can see the test result in the Log Viewer and Console in Katalon Studio GUI.

I am happy with this approach now.


I made a Feature Request to make the keyword builtin:


I have an idea of making junit4ks a Katalon Studio Plugin in future. Principally for the sake of myself. I use it in almost all of my Katalon Studio projects. So I need an easy way to install the junit4ks in my projects.

So I renamed the package com.kazurayam.ksbackyard.junit to com.kazurayam.junit4ks for better catch.