JUnit4-Katalon Studio integration by a built-in keyword

I have updated my github project:

there I proposed a custom keyword class com.kazurayam.junit4ks.JUnitCustomKeywords with a keyword method runWithJUnitRunner(Class clazz). This keyword enables me to run JUnit-based tests for my Custom Keywords (which interacts with web sites via WebDriver) in Katalon Studio, and to view test results in concise format in the LogView/Console pane. It would make it a lot easier for me to develop custom keywords in Katalon Studio.

I would request @Katalon Team to provided a similar keyword built-in the Katalon Studio.


I have updated my github project.

The previous version emitted a log when a test case failed, but the log did not show the exact point of failure: which test case class, which method, which source code line caused failure. The new version emits more informative message, something like this:

2019-01-18 05:37:31.543 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/test/com.kazurayam.ksbackyard.junit/JUnitCustomKeywordsTestRuuner
2019-01-18 05:37:32.380 DEBUG testcase.JUnitCustomKeywordsTestRuuner   - 1: com.kazurayam.ksbackyard.junit.JUnitCustomKeywords.runWithJUnitRunner(com.kazurayam.ksbackyard.junit.JUnitCustomKeywordsTest, CONTINUE_ON_FAILURE)
2019-01-18 05:37:32.767 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ These following reason:
	Expected: is "\taaa\n\tbbb\n\tccc\n"
	     but: was ">>  aaa\n>>  bbb\n>>  ccc\n"
		at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
		at org.junit.Assert.assertThat(Assert.java:956)
		at org.junit.Assert.assertThat(Assert.java:923)
		at org.junit.Assert$assertThat.callStatic(Unknown Source)
		at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
		at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
		at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
		at com.kazurayam.ksbackyard.junit.JUnitCustomKeywordsTest.testIndentLines(JUnitCustomKeywordsTest.groovy:18)      // .... this is the exact point where the test case failed
		at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)

The change diff is here.

1 Like

Should I consider making this a Plugin, rather than waiting for Katalon Team to implement this as a built-in keyword?


Yeah given the current status of our backlog, plugin would be a better way. We will update the Gradle plugin so that it can package Katalon Studio projects as custom keyword plugins.

In case you want to show JUnit test cases as Katalon Studio’s ones see this diff https://github.com/kazurayam/junit4ks/compare/master...devalex88:master.


Thank you very much. I have verified your change, and I liked it. I merged to the master branch. I got the tag 1.6:

Now com.kazurayam.junit4ks.JUnitCustomKeywords.runWithJUnitRunner() runs as if it were a built-in keywords.


For KS v7.2.6 here’s a fix for the JUnit classpath issue: