How to write Katalon Studio tests with IntelliJ IDEA and other IDEs


#21

#22

I’m convinced @kazurayam is writing a book - Katalon: The Missing Manual :smiley:


#23

Love this thread. slowly but slowly is about reinventing the wheel :smiley:
Why not simply use IDEA+groovy+Spock?

apply plugin: 'groovy'

group = 'org.spockframework'
version = '1.0-SNAPSHOT'

description = """Spock Framework - Example Project"""

sourceCompatibility = 1.8

repositories {
        
     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.5.2'
    compile group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.7.1'
    testCompile group: 'org.spockframework', name: 'spock-core', version:'1.2-groovy-2.5'
    testCompile group: 'com.athaydes', name: 'spock-reports', version:'1.6.1'
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.13'
}

tasks.withType(Test) {
    systemProperties System.properties
}

that’s all you need


#24

Thank you @Ibus that’s definitely another great option. At this moment we haven’t published our Maven-based libraries so if they are required dependencies the setting up will be a little bit tricky.


#25

Well, we are not reinventing the wheel. I want to do unit-testing for custom Keywords with JUnit. In the Katalon Studio GUI it was difficult. Therefore devalex88 proposed alternative way: do it in IDEA or Eclipse. We are reusing the best wheels, aren’t we?


#26

By the way :grin: , I miss “Page Object” in Katalon Studio. I hope I could reinvent the wheel called “Page Object” in Katalon Studio.

Martin Fowler wrote :

However, if you write tests that manipulate the HTML elements directly your tests will be brittle to changes in the UI.

Test Objects in Katalon Studio manipulate HTML elements directly, so my Katalon tests will be brittle to changes in UI.

The “Object Repository” stuffed by “Web Recorder” tool tends to be huge in size where hundreds of duplicating Test Objects are contained. A huge Object Repository is simply hard to maintain. Due to this concern, I would rarely use “Web Recorder” for testing a large-scale Web UI. I have a hope that introducing “Page Object” pattern into Katalon Studio would enable us to reduce the size of “Object Repository”.

I have some web-ui testing projects of mine which use IDE+Groovy+Gradle+WebDriver+Spock+GEB. GEB provides nice implementation of Page Object pattern. I like this tool set.

But I still love Katalon Studio primarily for its easiness for non-programmers (my colleagues at work) to getting started with. They can not get started with the “IDE+Groovy+Gradle+WebDriver+Spock+GEB” tool set ever; it has too much of technical prerequisites — they can not set it up at all.

So I miss “Page Object” pattern in Katalon Studio.


#27

@kazurayam i was just kidding. honestly i love the workarounds proposed.
@devalex88 mhm … i have an idea … not sure if will work.
What if we grab all the jar’s from katalon plugins and bring them into an IDEA project (maven or gradle) ?
In theory if they are in a standard place we should be able to use them …

I have to find some time next week to play with this, in vacation now …


#28

#29

I have given up the idea of testing my custom keywords with JUnit outside Katalon Studio; I mean in Eclipse.

I want to do unit-tests on my custom keyword class com.kazurayam.ksbackyard.ScreenshotDriver. This class interacts with WebDriver to take screenshot of web sites, therefore it requires the Katalon Studio runtime environment. It is impossible to mock the KS runtime environment in Eclipse, so I gave up.

I am going to investigate 2 more options, both will be performed within Katalon Studio GUI:

  1. Use Cucumber (which is built-in Katalon Studio) for testing my custom keyword classes
  2. Develop another custom keyword “runJUnit” and call it in ordinary Katalon Test Cases. The keyword should make it easier to run JUnit tests located in the Includes/scripts/groovy directory. I also want to find some way to view the testing results in concise format.

#30

I started learning Cucumber in Katalon Studio. I read https://docs.katalon.com/katalon-studio/docs/running-cucumber-features-file.html#in-test-cases and found such sample code:

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
         
@RunWith(Cucumber.class)
@CucumberOptions(features = "Include/features", glue = "")
public class MyCucumberRunner {}

Well, this code is using org.junit.runner.RunWith. In other words, Cucumber is running on top of JUnit. I have got a clearer view how Cucumber is integrated into Katalon Studio.


#31

I have developed a custom keyword which integrates JUnit in Katalon Studio. See the following post: