How to define Global Variables within Scripts, i.e. "on the fly"?

Yeah, I had a few days off, so I could not answer until now. I find your POM approach quite interesting for some more ambitious challenges. But, as already mentioned, because of the disadvantages with the Manual View I will now probably concentrate on kazurayam’s proposal to define one identically named global container map variable for all my projects and then develop a project creation wizard as a PowerShell script that copies all respectively required template files to the right places.

Thanks again and regards!

Drunda,

Good luck!

Thank you. :slight_smile: But I have to say, just the reliable renaming of a template project (including changing all file names and paths entered in configuration files) is not a trivial thing. Maybe that’s why I’ll switch from PowerShell to AutoHotKey to let Katalon Studio do some of the necessary process steps itself…

just the reliable renaming of a template project (including changing all file names and paths entered in configuration files) is not a trivial thing.

I know. When renaming the project Katalon Studio seems to be doing a lot of messy jobs; nothing documented; dirty reverse engineering required.

I’ll switch from PowerShell to AutoHotKey to let Katalon Studio do some of the necessary process steps itself

This sounds better. I am interested in it.

Once you succeed, please share your experience here.

Once you succeed, please share your experience here.

I will. But please have a little patience, on my todo list it’s pretty far behind at the moment.

Maybe that’s why I’ll switch from PowerShell to AutoHotKey

I use AHK a lot… strangely, not with KS. I think maybe you’ve sown a seed, Drunda.

That pleases me. :slight_smile:

@4280-kazurayam:

Above you explained the following:

I made a project in Eclipse where I developed these classes. I made a
jar file which contains the com.kazurayam.ksbackyard package. Then I
added the jar into my Katalon projects using External Libraries feature.
Once the jar is added, all the com.kazurayam.ksbackyard classes become
available to my custom keywords.

I guess your jar libraries are written in Java, not Groovy, right? Since I am not an experienced Java developer and only learned a little Groovy through Katalon Studio, I would like to outsource my Custom Keywords as jar libraries to be able to reuse them flexibly in different projects. I have started a new thread on this topic:

Do you think you could give me some more tips on how this could be done, please? So far no one was able to contribute to this.

Many thanks + best regards!

Yes, with pleasure.

I would show you my products. There are rather complicated. so that not suitable for your reference. Just to show you that I can show you something.

Here is a “outsourced” project:
https://github.com/kazurayam/KatalonStudioBackyard

Here is a project which uses the above project’s product.
https://github.com/kazurayam/HappyMigrationSiteTest

The HappyMigratinSiteTest project peforms a series of automated test against a web-site hosted by the company I work for. The site has a lot of outgoing links like . I wanted to test these links are OK or not. The verification rule was complicated enough.
- Some links may be simply broken. The href’ed URL is no longer there. o:)
- Some links may return HTTP Status=503 Redirected to some other URL. Is it ok or no? It depends. :*
- Some links may return HTTP Status=200 OK, but its body contained a message “page is not found”. :s

Katalon Studio fell short for verifying those problematic links so that I developed a custom keyword. My keyword drives Apache Commons Http Client for itself, make a HTTP resuest, receive a HTTP response, check the response status and check the body to determine the validity of the responded contents. Developing my keyword was complicated enough. It deserved a thorough Unit-testing by Spock or JUnit. In Katalon Studio, it is impossible to run unit-testing for custom keywords. This was the very reason why I established another Eclipse project KatalonStudioBackyard apart from the Katalon project HappyMigrationSiteTest.

The project “KatalonStudioBackyard” is

  • an Eclipse project
  • developed in Groovy language
  • Groovy codes in this project do NOT depend on the com.kms.katalon.* libraries.
  • this project outputs a jar file which is supposed to be imported by other Katalon projects

The “HappyMigrationSiteTest” project imports the jar file provided by the Backyard project. In the “HappyMigrationSiteTest” project, I have a set of Keywords. The keywords depend on com.kms.katalon.* libraries. What a keyword does is

  1. instanciate a Groovy classes developed by the KatalonStudioBackyard project
  2. calls its methods with arguments passed by testcases to execute business logic
  3. check the returned result. If any failure found, call KeywordUtil.logFailure(msg), log messageis with WebUI.comment(msg).

My keyword is very thin layer, is just a few lines of Groovy. Most of the business features are encapsulated in the classes in the KatalonStudioBackyard project.

Drunda,

Possibly you need to refactor your current Groovy codes into 2 layer:

  1. com.kms.katalon.* dependent portion — entry point for Test Cases, logging, reporting etc
  2. independent portion — business logic
1 Like

I already suspect there’s great work in your references again. I am quite curious about it. But unfortunately both your links don’t work. Could you please check them again? Thank you very much! :slight_smile:

Drunda,

I think that you should run through a tutorial for “Groovy programming in Eclipse”. I googled and found the following article:

Drunda,

Here is a “outsourced” project:
https://github.com/kazurayam/KatalonStudioBackyard

Here is a project which uses the above project’s product.
https://github.com/kazurayam/HappyMigrationSiteTest

Scratch that. I remember now. These 2 repositories are private. You can not get access to them.

The latter HappyMigrationSiteTest project contains some sensitive information, so that I can not disclose it public.

The former KatalonStudioBackyard has contents that could be an open source project aiming to be useful for users of Katalon Studio, I have not worked out yet.

There is a simple reason why I had to make the project KatalonStudioBackyard independent from com.kms.katalon* packages.

Katalon team does not provide a jar file which contains com.kms.katalon.* packages to be used in other projects. No jar there. Therefore I could not make the KatalonStudioBackyard project dependent on the Katalon Studio API.

I put +1 to the following post.

:stuck_out_tongue:

The latter HappyMigrationSiteTest project contains some sensitive information, so that I can not disclose it public.

The former KatalonStudioBackyard has contents that could be an
open source project aiming to be useful for other Katalon Studio users.
But I have not worked out yet.

Oh, that’s a pity, but of course it goes without saying. Needless to say, I would be very happy if you could still make the KatalonStudioBackyard available in a harmless basic version. :slight_smile:

The HappyMigrationSiteTest project for the most part will probably be this one I already came across in another post from you, right? :slight_smile:

Thanks also for your reference to the Groovy in Eclipse Tutorial, I’ll check it out.

But in order to estimate whether the overhead of such a backyard project to be developed in Eclipse is at all necessary for my purposes, could you please go into the following point in some more detail?

Developing my keyword was complicated enough. It deserved a thorough
Unit-testing by Spock or JUnit. In Katalon Studio, it is impossible to
run unit-testing for custom keywords. This was the very reason why I
established another Eclipse project KatalonStudioBackyard apart from the
Katalon project HappyMigrationSiteTest.

Unfortunately, I still have no immediate experience with Spock and JUnit and therefore have no precise idea of the advantages you have gained through this approach that were not possible in Katalon Studio.

Thanks a lot + best regards

Drunda,

You have developed your custom keywords without unit-testing. If you are comfortable with it, then you do not need to worry about Spock and JUnit. All you need to do is to introduce code sharing in your team.

Do you think you could give me some more tips on how this could be done, please?

For this to achieve, a Git remote repository is a mandatory tool.

Do you use Git remote repository to share code with your collegue? GitHub, Bitbucket on internet, or a GitLab server on your company’s intranet?

My approach was as follows:

(1) You develop codes to be shared in the Backyard project. You compile the Groovy source files to create JVM class files, and output a jar file which contains the class files.

(2) Your team mate setup their Katalon Studio project so that the project imports the jar. He/she will develop Keywords using the classes imported via jar.

Drunda,

I suppose my approach is not well fitting to your case. I suppose all you need is some tool to copy the Groovy source codes you developed into the target Katalon project, that’s all. Do you agree?

Do you use Git remote repository to share code with your collegue?
GitHub, Bitbucket on internet, or GigLab on your companies interanet?

So far, we haven’t. But for other purposes Bitbucket is already used in our company (only not yet by me). That’s why it’s exactly what we’re planning for the distributed work on Katalon Studio projects.

I suppose my approach is not well fitting to your case. I suppose all
you need is some tool to copy the Groovy source codes you developed into
the target Katalon project, that’s all. Do you agree?

No, I don’t think so. In my other thread on this topic I had already described our situation in more detail:

I have developed some Custom Keywords for various Katalon Studio
projects in our company. Up to now I synchronized the contents of the
last edited project’s Keywords directory manually to the Keywords
directories of all other projects. However, this process is becoming
increasingly confusing and error-prone.

In addition, we will
continue to work on the projects in distributed teams in the future,
whereby I will take care of the further maintenance of the Custom
Keywords as well as the initial creation of new Test Suites. On the
other hand, the product managers and developers of the applications to
be tested should be able to edit the Test Suites (and especially the
included Test Cases) independently in the event of necessary adjustments
and, if necessary, also jump back to earlier versions of my Custom
Keywords basis.

Therefore I would like to maintain and version my
Custom Keywords a little more professionally as a general code base for
all projects. But as far as I understand the interaction between
Katalon Studio and Git so far, the testing projects can only be
versioned as a complete package, right?

So I guess the best way
to achieve my goal would be to pack my Custom Keywords into jar
libraries that could then be included in any other Katalon Studio
projects. Unfortunately, I have no experience with Java projects in
general or with Maven in particular - is this where Maven comes in? Or
is there another “best case” to implement this? And what exactly would I
have to do?

So two important requirements would be that the code for the Custom Keywords and, on the other hand, the code for the Test Suites (especially the Test Cases) as such …

  1. could be further developed independently of each other and
  2. could be combined with each other as desired.

I think that’s exactly why it will be necessary to pack the Custom Keywords into a jar file that I can version and distribute separately, don’t you think?

I’ve heard of Git also supporting so-called submodules for such purposes. However, I was strongly advised against using them because of their error-prone handling.

Finally, with all these thoughts in mind, I wonder how I could easily compile my Keywords Groovy files (without the entire Eclipse overhead, if possible) and and make them available as jar libraries to other teams using the Katalon Studio testing projects.