How to integrate a java module directly in Katalon?
Thanks for the update.
We have a scenario to include the custom module directly to the Katalon Studio.
Is it possible? - if yes, could you please help me how we can add any java/android module directly in Katalon Studio project?
The reason I am more interested to integrate the module directly in Katalon Studio project because it would get rid of the manual process for generating the jar all time.
In the future, if I need any changes in my module then I can directly update over Katalon Studio project.
Please Let me know if this module integration support available in Katalon Studio or not.
That’s exactly what I linked you already. Maybe I am misunderstanding your requirement? What do you mean by “integrate the module directly in katalon”? Do you mean adding the source code to Katalon?
Thank you for your prompt reply.
Yes, need to add the source code module directly in katalon studio. Bcz My test scripts are dependent of those source code module. In future If I need to update this source code module, then I can directly update in the Katalon Studio and run the script.
Katalon Studio allows us to place our own Groovy source files into 2 places.
- in the
- in the
See the following screenshot:
It does not matter how you create the *.groovy files — either you copy file from somewhere else, or you do copy&paste using editor, or you type the code from scratch. Once written, you can directly update the code anytime you want, of course.
Is it what you want to do? If so, just do it. Nobody would stop you.
Thank you for the update.
My module source code contains:
- java files
- xml files
I want to add both java file and with xml files in a package because all files are interrelated.
Could please guide me on this how Katalon studio provides support to add those files in a package?
- java files
You can copy your *.java files into either the
Keywords folder or the
Includes/scripts/groovy folder, and rename them *.java -> *.groovy. Then the Groovy compiler built-in KS will happily compile the *.groovy files into the *.class files.
- xml files
You need to locate the *.xml files into a folder which is configured as a part of CLASSPATH. How you can find it? — You can find a
<projectDir>\.classpath file in a Katalon Studio project. You need to check it. For example the following an example .classpath file of one of my KS project. The .classpath file is created and used by KS.
.classpath.txt (15.6 KB)
In the .classpath file you can find a line
<classpathentry kind="lib" path="C:/Users/qcq0264/katalon-workspace/junit4ks/Drivers/ashot-1.5.4.jar"/>
This line proves that any jar file contained in the Drivers folder is looked up by KS and included in the runtime classpath.
… as far as I see the .classpath file, unfortunately for you, there is no appropriate folder where you can locate your .xml files so that the *.xml files are included in the runtime classpath.
I think, you should create a jar which contains *.class files and *.xml files, and bring that jar into the Drivers folder.
You should make a jar of your library in the origin project first. Then import the jar into the KS project’s Drivers folder as @Brandon_Hein mentioned. This is the way you should follow.
If your KS project depends on several external jar files, the following post describes how to resolve the dependencies and import the relevant jar files into the project’s Drivers folder.
As far as I know this approach is the only way to resolve complex dependencies to external jars.
This is against the DRY principle. I wonder why you want to do this.
I am afraid I haven’t understood your intention.
Can you please detail a bit what to you intend to achieve and what is the structure of your application?
The only reason for doing it like it is, usually, when writing unit-tests.
Katalon it is not designed with this scope in mind, but it is designed for functional testing (end-user approach). For this scope, ideally the test tool/code should not depend or be aware of the AUT code, otherwise it will only produce flaky results and headache, aka Heisenbugs
Starting in KS v7.4.0+, you can maintain and edit your Java code in Katalon Studio. Please see it for details: https://www.katalon.com/selenium-test-migration/?utm_source=selenium-migration-home-page
How about *.xml files as resource? Where in a Katalon Studio project can I locate my logback.xml file?
In https://docs.katalon.com/katalon-studio/docs/selenium-testng-junit-migration.html, to my surprise, I found a sentence:
Supporting viewing, editing, and creating Java class files under the Include/scripts/groovy
I do not like this idea. What a mess! I would reject mixing up *.java files into a directory named
groovy! Are you going to put *.js files there as well in future?
Why did you not add “src/main/java”, “src/test/java” or “src/katalon/java” as the Maven Standard directory layout proposes?