Transforms and Katalon

I’m having an issue applying a transform to my Katalon script. This is the documentation of the transform:

Currently, I’m trying to implement a suggestion @Russ_Thomas gave me a few days ago. My goal is to ultimately have a testCase stop if too much time has passed by using the transform above. I’ve heard that CI would allow me to do this easily, but I need to do my due-diligence with the tools I have at hand first. Namely Katalon Studio and KRE. Oh, and you lovely folks who will likely say I made a groovy mistake :grin: Hopefully.

Here’s my basic script to test the concept:

/ * default import statements.

import groovy.transform.TimedInterrupt
import java.util.concurrent.TimeUnit

@TimedInterrupt (value = 75L, unit = TimeUnit.SECONDS)
public class TestFoo {
     def letsGo(){
            WebUI.callTestCase(findTestCase('repository path'), ['':''], FailureHandling.STOP_ON_FAILURE)
test = new TestFoo()

The called test case has the form:

/* usual imports

CustomKeywords.'web.login.URL'(env)   //this keyword just opens a browser and goes to the correct environment. Nothing to see here.

for (iter in 0..10){

The expected behavior is the WebUI.delay(100) is far longer than the expected timeout time, but the testCase is still called. Moreover it actually iters through all 5 minutes of refreshing without an issue!!

Anyhow, I feel like I’m misunderstanding something fundamental about Java/Groovy and declaring objects, classes, and methods. Cheers and Happy Friday!!

Same here, though in my case I’m falling foul of this in docs:

Annotating a class will cause (by default) all classes in the entire file (‘Compilation Unit’) to be enhanced. You can fine tune what is enhanced using the annotation parameters. Static methods and static fields are ignored. Link

My iterator method is static.

Doesn’t help with your problem, though.

1 Like

Right, that’s why I went as basic and simple as possible. Sure, I don’t know if methods within WebUI may have this property as well (haven’t dug around in their code, so I’m not sure), but at the very least the for-loop ought to be transformed.

Edit: assuming I set everything up properly, of course.

Briefly scanning your code, nothing leaps out at me as being wrong.

(I’m about to edit your OP to make the code look nice – when I’m done, edit it yourself to see what I did).

1 Like

Cheers, I haven’t mastered the mark down here.

So, notice, I tagged the first with ```javascript which I happen to prefer (even for Groovy).

Back to your real problem.

I’ve only ever tinkered with Groovy metaprogramming so I’m not sure where to go from here. You could try – merely as an exercise – changing your code to…

while(true) {

Might be pointless but who knows :confused:

Other than that, @kazurayam has done more with metaprogramming, let’s see if he has any pointers.

I do not understand the discussion between @joel.scott and @Russ_Thomas.

I read , interested in it, tried to apply it somehow.

See the following “Test Case/TC1” and “Keywords/my/SuicideBomber”

When I executed “Test Case/TC1”, it run for approximately 10 seconds and killed itself.

If I want to change “TC1” to be alive longer, then I would change the source of “SuicideBomber” from

@TimedInterrupt(value = 10L, unit = TimeUnit.SECONDS)

to, for example,

@TimedInterrupt(value = 60L, unit = TimeUnit.SECONDS)

The TC1 will run 60 seconds, and after that, will kill itself.

Please note that “TC1” has a for loop. The loop repeats calling the SuicideBomber#tick() method, which triggers Test Case to suicide when the time has come.

However, perphaps, the Test Case script of @joel.scott does not have such for loop in it. Without such loop in his Test Case scripts, @TimedInterrupt will never fire.

I understand that @joel.scott want to stop a long-running test case by setting a timeout regardless the reason why the test case is running longer than he expects. As told above, @TimedInterrupt does not help. And, as far as I know, Katalon Studio does not offer setting timeout. So I think that he needs help by external monitoring process outside Katalon Studio: Continuous Integration servers, such as Jenkins and TeamCity.

Well, thanks.

Yep. Thank you. I’m a fool.

I needed to have my loop living in the right part of the code for the transform to work. :slight_smile:

Ya’ll are great.

1 Like