[Cucumber] Run with Cucumber Runner

Hey @staniere , I am facing an issue with Cucumber keywords as they are not available in Katalon 8.2.5 version. can you suggest what would be the best solution ?
A. Reinstall the Katalon Studio to lower version or something ?
B. Reinstall the cucumber jar or anything ?
C. Update any config detail and make it work ?

Appreciate your reply.

hello @magesh.mariappan,
I have no solution for the moment (always got an old cucumber version integrated in katalon).

I opened a ticket in katalon support and they said they will look at upgrading cucumber version in the future

for your problem, I have no idea sorry

@magesh.mariappan
@staniere

Have a look at

Please pay attention to

Exclude built-in libraries

With the ability to remove built-in libraries stored in the .classpath file of a project folder, you can replace a built-in library with an external one for flexible libraries usage in a test project.

Important
This feature applies to all libraries in classpath , excluding:

  • io.cucumber.*.jar

Excluding those libraries may cause failure of the relevant features.

As you see, Katalon suggest to users not to try upgrading the io.cucumber.*.jar.

But you could try it and see what happens.

If you are going to try upgrading the cucumber-core-*.jar, you need to know

  1. which old built-in jar you need to remove out of the .classpath file
  2. which new version of jars you should copy into the Drivers folder

Here I assume you are sure you want the cucumber-core-5.7.0.jar. Then what else? The cucumber-core-5.7.0.jar would depend on other cucumber-something-x.x.x.jar so that you need to upgrade them at the same time. Unfortunately Katalon Studio provides no help to diagnose the dependency tree.

I would show you how to retrieve the dependency tree.

First you need to install Gradle into your machine. You need to be able to do the following operation in the command line:

$ gradle -version

------------------------------------------------------------
Gradle x.x.x
------------------------------------------------------------

Change the <projectDir>/build.gradle file as follows:

ext {
  AUTO_IMPORTED_JAR_PREFIX = 'AUTOIMPORTED_'
}

repositories {
  mavenCentral()
  mavenLocal()
}

configurations {
  myconf
}

dependencies {
	// https://mvnrepository.com/artifact/io.cucumber/cucumber-core
	//myconf group: 'io.cucumber', name: 'cucumber-core', version: '7.2.3'
    myconf group: 'io.cucumber', name: 'cucumber-core', version: '5.7.0'

}

task drivers {
    doFirst {
        delete fileTree("Drivers") {
            include("**/" + AUTO_IMPORTED_JAR_PREFIX + "*")
        }
    }
    doLast {
        copy { copySpec ->
            copySpec
                .from(project.getConfigurations().getByName("myconf"))
                .into("Drivers")
                .include(
                    "**/cucumber*.jar",
                    )
                .rename({ s ->
                    AUTO_IMPORTED_JAR_PREFIX + s
                    })
        }
    }
}

Then in the command line you want to run the following command:

$ cd <projectDir>
$ gradle dependencies

> Task :dependencies

------------------------------------------------------------
Root project 'KS_upgrading_cucumber_jars'
------------------------------------------------------------

myconf
\--- io.cucumber:cucumber-core:5.7.0
     +--- io.cucumber:cucumber-gherkin:5.7.0
     |    \--- io.cucumber:cucumber-plugin:5.7.0
     |         \--- org.apiguardian:apiguardian-api:1.1.0
     +--- io.cucumber:cucumber-gherkin-vintage:5.7.0
     |    \--- io.cucumber:cucumber-gherkin:5.7.0 (*)
     +--- io.cucumber:tag-expressions:2.0.4
     +--- io.cucumber:cucumber-expressions:8.3.1
     |    \--- org.apiguardian:apiguardian-api:1.1.0
     +--- io.cucumber:datatable:3.3.1
     |    \--- org.apiguardian:apiguardian-api:1.1.0
     +--- io.cucumber:cucumber-plugin:5.7.0 (*)
     +--- io.cucumber:docstring:5.7.0
     |    \--- org.apiguardian:apiguardian-api:1.1.0
     \--- org.apiguardian:apiguardian-api:1.1.0

(*) - dependencies omitted (listed previously)

As you see Gradle tells you the dependency tree of cucumber-core.0.5.7.jar.

I found that cucumber5.7.0 depends on org.apiguardian:apiguardian-api. Is it built-in KS? I am not sure.

You can try

$ gradle drivers

Then you will find several jar files are copied into the Drivers folder.

$ ls Drivers
AUTOIMPORTED_cucumber-core-5.7.0.jar
AUTOIMPORTED_cucumber-expressions-8.3.1.jar
AUTOIMPORTED_cucumber-gherkin-5.7.0.jar
AUTOIMPORTED_cucumber-gherkin-vintage-5.7.0.jar
AUTOIMPORTED_cucumber-plugin-5.7.0.jar

Now you have got 5 jars in the Drivers folder.

Finally, you have one more setup task to do. You want to follow the instruction at the doc, you should exclude the built-in 5 jars of old version built-in Katalon Studio.

You want to stop KS once, and restart it so that it acknowledges the newer jars prepared in the Drivers folder.


Please be warned that it is quite likely that upgrading cucumber-core causes error. It is quite possible that some code of Katalon Studio depends on the Cucumber API of v3.x, or some code of Katalon Studio does not understand the Cucumber API of v5.x. In that case, you should just give it up.

I found that KS v8.2.5 does not include the jar of org.apiguardian. Therefore you need to add it in the Drivers folder as well.

Please replace the build.gradle as follows`.

ext {
  AUTO_IMPORTED_JAR_PREFIX = 'AUTOIMPORTED_'
}

repositories {
  mavenCentral()
  mavenLocal()
}

configurations {
  myconf
}

dependencies {
	// https://mvnrepository.com/artifact/io.cucumber/cucumber-core
	//myconf group: 'io.cucumber', name: 'cucumber-core', version: '7.2.3'
    myconf group: 'io.cucumber', name: 'cucumber-core', version: '5.7.0'
    
    // https://mvnrepository.com/artifact/org.apiguardian/apiguardian-api
    myconf group: 'org.apiguardian', name: 'apiguardian-api', version: '1.1.0'

}

task drivers {
    doFirst {
        delete fileTree("Drivers") {
            include("**/" + AUTO_IMPORTED_JAR_PREFIX + "*")
        }
    }
    doLast {
        copy { copySpec ->
            copySpec
                .from(project.getConfigurations().getByName("myconf"))
                .into("Drivers")
                .include(
                    "**/cucumber*.jar",
                    "**/apiguardian-api*.jar"
                    )
                .rename({ s ->
                    AUTO_IMPORTED_JAR_PREFIX + s
                    })
        }
    }
}

@kazurayam - How are you passing Cucumber tags at runtime when using the Cucumber runner?

It looks like global variables aren’t supported inside of a groovy class.

The internal.GlobalVariable object is public. It is available for any groovy classes inside KS. If you find your class can’t get it, I guess your code has some mistakes. But you haven’t showed your code, logs, etc. So I do not see anything.

Please create a new post for your problem if you are going to raise a question.