How do I create reusable methods for workflows that are used repeatedly in my test cases?

I have certain workflows that are repeated and have to be reused in test cases. For this as I did not find an option such as global functions or reuseable workflows in Katalon I had to create test cases for these flows.

And my test case would be a set of these reusable workflows (that are created as test cases).

The problem with this approach is that the public variables are not displayed while bundling the test cases as test suite and hence cannot parameterize.

Katalon studio has been a great tool and suits the needs of my organization. The only limitation I am facing is with creating reuseable workflows. It would be great if you could give me a solution.

Thanks

1 Like

Shrikanth,

I think there are 2 ways we could achieve the approach:

  • Create custom keyword (not recommend) (https://docs.katalon.com/display/KD/Define+custom+keywords). With custom Keyword, we have the flexibility to create any workflows with parameter and then reuse it in the test case.
  • Create ‘workflow’ Test Case (I am not sure if this is the solution you were using, correct me if I am wrong). Since we pass params into any Test Case and then calling Test Case from another Test Case, we have the ability to use Test Case as a procedure, or a work-flow. When calling these Test Cases from the actual Test Case, we could pass any params: Global Variable, Data Set (data-drven) or default value.

Hope these solution help, and do not hesitate to discuss more on that.

I feel we are on the same page Trong,

  • We are not planning to use the custom keyword approach for workflows. We have used custom keywords to create reusable methods that will be used inside test cases and workflows.

  • Yes, we have currently used the same concept of workflow test cases in our project. ie; our Main test case is a combination of multiple workflow test cases. As you have said I had tried parameterising data into the main test case while calling the workflow test cases. But this is where I am facing a problem.

I am able to link the test data to the public variables in the main test case. But cannot find a solution to run the test case for all the rows in the test data as I will be using all the main test cases to form a test suite.

I had tried tried the “data binding” option in test suites and selected “run for all rows” but that did not iterate the test case. Well, I am aware we have an alternative through script using the “InternalData” class. But I am trying to figure out a way to utilize all the functionalities of the tool that is already implemented.

Kindly let me know, how to go about doing this (running for all rows in the test data).

Thanks

Hey Trong,

I think I have figured out a way. I have used public variables in my workflow test cases and the same variables in my main test case. So this enables me to assign data sheet values to my main test case public variables which in turn is applied to the workflow test case public variables.

Please do suggest if there is an other better way to parameterise.

Thanks

1 Like

My approach does cause a bit of overhead as I will have to define the public variables in both the workflow test and the main test case. Please let me know if there is a better approach.

@Trong Bui said:
Shrikanth,

I think there are 2 ways we could achieve the approach:

  • Create custom keyword (not recommend) (https://docs.katalon.com/display/KD/Define+custom+keywords). With custom Keyword, we have the flexibility to create any workflows with parameter and then reuse it in the test case.
  • Create ‘workflow’ Test Case (I am not sure if this is the solution you were using, correct me if I am wrong). Since we pass params into any Test Case and then calling Test Case from another Test Case, we have the ability to use Test Case as a procedure, or a work-flow. When calling these Test Cases from the actual Test Case, we could pass any params: Global Variable, Data Set (data-drven) or default value.

Hope these solution help, and do not hesitate to discuss more on that.

I have demostrated the approach I used in my project as below. The idea was that I created my workflow test cases as generic as possible and all of them have neccessary params to perform the action. These params are passing over steps with the value from Data binding area. For example: my Test Data is an excel sheet having data for a list of username, password and profile. These value are row-by-row passing to the test case in test suite, and finally passing to Workflow Test case.

Do you have the same approach or where is in the flow you have problem?

Test Case Workflow.png

Hi Trong ,

I really appreciate the effort you have made in explaining the architecture. Yes, we have even implemented the same.

The area of concern was that it takes two stages for the data to reach the workflow test cases.

In my opinion it could have been better to have a section for reusable methods (replacing workflow test cases) that can be linked to the test cases enabling us to directly pass the data to the test case from the test suite (one stage process).

Would be great if you could bring it as an improvement. However, from my very short experience using Katalon Studio got to admit you guys have done a fantastic job making test automation easier.

Thanks.

Thank you so much for the suggestion, Shrikanth. We will consider it seriously as an improvement and all together making Katalon Studio better and better.

3 Likes

Trong Bui said:

I have demostrated the approach I used in my project as below. The idea was that I created my workflow test cases as generic as possible and all of them have neccessary params to perform the action. These params are passing over steps with the value from Data binding area. For example: my Test Data is an excel sheet having data for a list of username, password and profile. These value are row-by-row passing to the test case in test suite, and finally passing to Workflow Test case.

Do you have the same approach or where is in the flow you have problem?

@Trong - This is an excellent approach with the current features in Katalon; however the concept of passing Data from Main TCs to Workflow TCs doesnt seem to work for me.
I have created variables under Main TC (this is called into Test Suite) that are used with Data binding. But these values are not passed into Workflow TC.
Can you suggest the right way of using variables and passing them around in this workflow approach?

@Trong Bui - Do you have a sample Katalon Project you can supply, showing your workflow in action? Perhaps against the Katalon demo site. I think it would be very helpful for new users of Katalon Studio like myself.

Thanks!

3 Likes

Trong Bui said:

I think there are 2 ways we could achieve the approach:

* Create custom keyword (not recommend) (https://docs.katalon.com/display/KD/Define+custom+keywords). With custom Keyword, we have the flexibility to create any workflows with parameter and then reuse it in the test case.

Hi @Trong Bui

Would you please elaborate on “not recommended”? Are you not recommending this approach? Or is this some “best practice” advice from someone/somewhere? If so, who? And where? I’d like to read it.

The reason I ask is, that method is the method I am using – to great success – and for exactly the reasons you state: “the flexibility to create any workflows with parameter and then reuse it in the test case”.

Jon West said:

@Trong Bui - Do you have a sample Katalon Project you can supply, showing your workflow in action? Perhaps against the Katalon demo site. I think it would be very helpful for new users of Katalon Studio like myself.

Thanks!

Jon,
I have it ready for my machine. Give me some time next week to make it public and update it to you.

Russ,

“Not recommended” - is my idea from the context of using “Katalon Studio” and Test Case of the topic.
Katalon Studio mainly has 2 parts: visual (manual) mode where testers can create steps, then combine them into Test Case for reuse or execution purposes. Another part is scripting mode where testers can create custom scripts for more complex tasks.

From the 2 modes, you can see that the first mode is for testers who may not have good programming skill, so they just use what provided in Katalon Studio and let our team maintain all the functionality (steps, generated scripts, driver handling, listener, etc). If there is sometimes in the future, we upgrade those features with different technical approaches, we will ensure that their tests keep working.

On the other hand, the second mode is for the tester who has better skill in programming. Katalon Studio provides them with all the flexibility to use programming languages so that they could perform more complicated scripts. It also means that they take their own responsibility to maintain their created scripts.

Both 2 approaches have pros and cons so I suggested the better option for specific users.

@Trong Buisuch great approach I am new to automation. waiting for your workflow project !

@Trong, Thank you for your approach. Looks like page object model framework.
can you help us sharing your sample project for public for all our understanding.

Would be a great help.

2 Likes

@"Trong Bui" - Will you be making the project public soon?

Thanks!

1 Like

Hi all,

I do apologize for the late update. Please find the example at following git: https://github.com/katalon-studio/katalon-demo.git

Notes:
Since the Application Under Test is our internal Jira system, so there are some configurations, accounts under test are NOT included in the git.

2 Likes

Dharmesh said:

Trong Bui said:

I have demostrated the approach I used in my project as below. The idea was that I created my workflow test cases as generic as possible and all of them have neccessary params to perform the action. These params are passing over steps with the value from Data binding area. For example: my Test Data is an excel sheet having data for a list of username, password and profile. These value are row-by-row passing to the test case in test suite, and finally passing to Workflow Test case.

Do you have the same approach or where is in the flow you have problem?

@Trong - This is an excellent approach with the current features in Katalon; however the concept of passing Data from Main TCs to Workflow TCs doesnt seem to work for me.
I have created variables under Main TC (this is called into Test Suite) that are used with Data binding. But these values are not passed into Workflow TC.
Can you suggest the right way of using variables and passing them around in this workflow approach?

how can we make a testcase which accept parameter?

utkarsh,

Here are some instructions on how to use test case with variables. Hope that it will help: https://docs.katalon.com/display/KD/Variable+Types

1 Like