Hii I am new to Katalon and would love if someone could help me out on the below issue,
Can I create a test case with multiple methods and invoke these methods as per need in other test cases? The callTestCase method calls the entire test case and not particular methods. I have explored custom keywords but was curious to explore this concept.
I tried creating a groovy class with methods only but could not find a way to invoke these methods in test case. It throws an error that method signature is not valid.
custom keyword is exactly what you need. It behaves as a regular Java class, so you can create methods there, then import the class in your test case and call the method you want.
Very easy example:
Custom keyword:
public class KeywordTest {
public static void sayHello() {
println "Hello!"
}
}
But then what is the purpose of creating methods in test case if we can’t reuse them and what is the purpose of creating groovy classes in scripts folder?
There is maybe only one such a scenario. If you repeat some test case specific action(s) multiple times, then you can define a method and call it instead of repeating code.
But as soon as you use your method in 2 or more tests, custom keyword approach wins.
Scripts folder does not contain groovy classes, but groovy scripts.
Therefore, as mentioned already, to create re-usable methods across testcases, you have to use Keywords (which are groovy/java classes)
To create reusable code inside testcase, one can use local methods
The Test Cases folder contains just some xml’s ( the .tc files) with some metadata. At the runtime, the actual scripts are located (not sure how, by parent folder name I suppose, because I cannot see any other match between the metadata and the script name) and compiled in classes.