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

@duyluong @ThanhTo

EDIT: Now an official bug. Resolution provided by @kazurayam. Can’t fault his diligence! :nerd_face:

Spoiler - Kazurayam's Fix

[OP from here]

For some reason, KS editor is complaining/underlining Date().format():

image

When the TC is executed, this happens:

ERROR c.k.k.core.context.internal.TestHooker   - ❌ org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: 
No signature of method: java.util.Date.format() is applicable for argument types: (String) values: [yyyyMMdd_HHmmss]
Possible solutions: from(java.time.Instant), stream(), getAt(java.lang.String), parse(java.lang.String), print(java.io.PrintWriter), print(java.lang.Object)

Yet, there is no evidence Date().format() has been deprecated:

So I don’t understand why it’s posting an error to the log. And that format is non-negotiable (will be used later in a JSON file which something else is expecting to read and split on “_” and have fixed length parts).

Did I mention? I hate dates :confused:

Temporary fix:

image

image

So the only question remaining, is this online reference outdated? What’s the correct source of info?

http://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Date.html

@duyluong

This message confuses me.

This message suggests that java.util.Date.from(java.time.Instant) is possible. But java.util.Date.from(java.time.Instant) doesn’t make sense to me at all.

Also the message suggests java.util.Date.getAt(java.lang.String), which does not make sense to me either. This signature looks strange. I guess it is defined experimentally by some non-java-native programmer who knows little about the standard naming convention of Java language. I believe that the well-trained Groovy team will NEVER create such silly method signature.

The message lists the following methods as ‘Possible solutions’:

  • from(java.time.Instant)
  • stream()
  • getAt(java.lang.String)
  • parse(java.lang.String)
  • print(java.io.PrintWriter)
  • print(java.lang.Object)

But in the Groovy JDK enhancement API document of java.util.Date I can not find these.

I guess that there is some bogus class (or javadoc) in the classpath of KS7.9.0, which pretends to be java.util.Date but not really is, effectively hides the official Date implementation by GDK.

I am concerned that the classpath of KS7.9.0 might have some hidden problem .

Yep. I kept throwing stuff at it until it worked. :confused:

I also couldn’t find anything about .format() being deprecated - the IDE just underlined it and the compiler threw an error almost as soon as the TC started.

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

Hi @Russ_Thomas, @kazurayam

After a discussion with our development teams, we see that Groovy v3.0 support is not ready yet for production in Katalon Studio v7.9.0 so we will move this feature to v8.0 official release to have enough time for evaluation and testing.
Please try out v7.9.0.rc2 with Groovy 2.4.20 support and let us know if you guys have any issues with it.

We especially thank @kazurayam who spent his time to deep dive into the problem and suggest the suggestion above.

Kind Regards,

1 Like