How to capture data from TC1 to TC2

Data(orderid) is created in TC1. The same data (orderid) is an input to TC2. Can be done using global var when the data iteration is only ONE for both TC1 and TC2. It becomes difficult to manage with global variables when I have more than one Iteration. Any tips or suggestions to handle this situation

Use a Map?

I see 2 options. First, you can write in a file in TC1 and read from it in TC2. Second, you can call TC1 inside TC2 and have TC1 return data, such as a list or a map.

More robust idea is write in excel or csv and use in next test cases.
For example if one data generated in TC1 then you can save in csv and again you can read from csv in TC2

you are overthinking. tc1 should exchange data with tc2 only in current iteration. you colect at the end the final results if needed

Thanks all. Yes I know excel, files or such things work but the problem is how do I maintain the mapping between iteration #1 of tc1 vs Tc2. Especially when there is a failure in one of iteration.
We are currently progressing and implmenting using global variable and lists.

I agree with @Ibus, it seems you’re over-thinking the situation – either that or I don’t understand the issue as you’ve described it.

markFailed* will mark a test as failed (and stop, if you want).

KeywordUtil.markFailedAndStop("This test failed because...")

Let me explain this with an example.
TC1 - Create an Order. Output of this script is OrderID which is captured from the screen
TC2 - Cancel Order. The input to this script is OrderID of the order created in TC1.

Testsuite1 contains TC1 and TC2.

  • I have 5 iterations each for TC1 and TC2

Now I want to pass the 5 ORDERIDs created from 5 iterations of TC1 into TC2. I dont want to use Excel and files. What are your suggestions?

If there was only one iteration for TC1 and TC2 then I could have used GLOBAL Variables.
Other considerations:

  • I already have tried global lists/arrays. This becomes tricky when one of the iteration of TC1 fails. How do I handle the corresponding iteration in TC2.

_The scenarios mentioned are only for explaination, my actual scenarios are more complex. _

Okay - that’s a better description. Thanks.

Your issue then, is controlling what happens when any single instance of TC1 fails. You need to capture a failing value so that all five iterations complete.

Have you tried using callTestCase? You could wrap the calls to TC1 in a try catch and store a fail sentinel in your map/list/array which you can then look for during the TC2 iterations.

1 Like

Thanks @Russ_Thomas . We have already build the test cases (100+). The idea to use the test data from tc1 to tc2 came in late. So redesigning all the test cases is effort.

Also, for predictable failure cases, we can handle it via sentinel. But un predictable failures suchn webelement not found or such selenium exceptions, the script will fail intermittently and will not get to the step where a sentinel value is assigned for list/array.

For such situations, we are going to use testcase listeners, capture the status of execution and assign a value in the list for failed/errored cases. This is the work arounds. I will keep you posted

I was more interested to know if Katalon have any builtin feature to handle such situations. it is bound to happen in all testing frameworks. will be a great feature for katalon when there are big test automation projects

Maybe I don’t understand the situation but, could you have a custom object in TC1, with the properties you want. It could be a list of OrderID, if the ID is null then it wasn’t created in the first place. You could then send this only object to TC2.

Order idlist =[1,null,3]
according to your suggestion, the orderid list will be [1,3] since the second one was failure.
In such a case, my TC2 will use order id 3 into second iteration where as in reality there is a dependency that 3 should be used by 3rd iteration only.

Not really. You could match Order idlist with the TC3 so in TC3 you always use idList[3]. In TC2 you can check if idList[2] is null too and do what you want after that.

Agreed. How do i extract the iteration number to pass in n for idList[n]