Katalon Studio 7.9 rc - Bug in Date().format(<String>)

I have found the solution for the aforementioned “date.format(String)” problem.

ANSWER: Katalon Studio 7.9.x needs to bundle the jar file of groovy-dateutil in the Katalon Studio distributable.


Let me tell you what I have found.

I used Katalon Studio 7.9.0-rc to study.

I wrote a Test Case script as follows:

import org.apache.groovy.dateutil.extensions.DateUtilExtensions

println(Date.class.getResource(Date.class.getSimpleName() + '.class'))

println(DateUtilExtensions.class.getResource(DateUtilExtensions.class.getSimpleName() + '.class'))

Date now = new Date()
System.out.println(now.format("yyyyMMdd_HHmmss"))

In the bare KS 7.9.0, this code does not even compile as the following screenshot shows:

The error message says

1: unable to resolve class org.apache.groovy.dateutil.extensions.DateUtilExtensions
 @ line 1, column 1.
   import org.apache.groovy.dateutil.extensions.DateUtilExtensions
   ^

What is the DateUtilExtensions class? See the Groovy API doc:

http://docs.groovy-lang.org/docs/groovy-3.0.0/html/api/org/apache/groovy/dateutil/extensions/DateUtilExtensions.html#format-java.util.Date-java.lang.String-

This class defines new groovy methods which appear on normal JDK Date and Calendar classes inside the Groovy environment.

The date.format(String) is defined by this DataUtilExtensions class. So we need its implementation class to be included in the runtime classpath in Katalon Studio 7.9.0.

In which jar this class is included? — There is a jar named groovy-dateutil

According to the history info on Maven Central, the groovy-dateutil package was created as of Groovy-2.5.0. On the other hand, Katalon Studio 7.8 and older uses Groovy 2.4.7, and it uses groovy-all-2.4.7.jar. As of Groovy 2.5.0, the groovy-all-x.x.x.jar is not distributed any longer. Katalon Team has to choose which groovy-XXX.jar to bundle in the Katalon Studio 7.9.0-rc distributable. I was informed of this background before in this post.

I suspect that Katalon Team just forgot to include the groovy-dateutil.jar.

I downloaded the groovy-dateutil-3.0.7.jar from the Maven Central and saved in the Drivers directory of my Katalon project. Restarted KS. Then the test case script successfully compiled and ran OK.


Lesson learned

It is likely that Katalon Studio 7.9.0-rc misses some other groovy-XXXX.jar files which are essential and mandatory. Therefore we may see more cases where Groovy 3.0 behaves strange in KS 7.9.0-rc.

1 Like