Good day community. Question about callTestCase, if the test case I’m calling has default values for a variable or two defined, and I set these same variables in the test case that is calling this other test case, which variable values should I expect to see used by the called test case. Man I did not word that very well.
Test Case A - defines myVariable = “Toast”
Test Case B - defines myVariable = “Butter”
Test Case A calls Test Case B, is myVariable = Toast or Butter? I guess I could get an error trying this as well
Thanks for any help, I’ll play around with this and see what my results are. My goal is to override the values in the Test Case being called, if there is another method to doing this, info on how I would go about doing so is greatly appreciated.
Thanks Keith, looks like Local Variables is what I was looking for. I’ve found a way to set my value in the calling test case and have the called test case read it. This will be very handy for re-using code.
My scenario may be a little different, I’m not reading the value in from an excel file, but I’m sure the basic concept is the same.
So in Test Case A I create a variable called myVariable and give it a default value (optional I suppose). The only thing this Test Case does is output the value of that variable. In the examples below you can see where I defined the value and the output when I run the test case.
In Test Case B I’m calling Test Case A and setting the value of myVariable. Then when I run this test case you’ll see that Test Case A is outputting the value set on Test Case B, not the default value set in Test Case A.
I have tried to give same variable name but I did not have any success.
So basically I am trying test checkout process and I have created each step into test case and I have created one test case and calling each test case(for each page) into this main test case and My idea is to pass all the variable for each test case into this main test case.
I have tried assigning same variable name as test cases and Main test case and that option did not work and it would pass the variable from main to other test cases.
I guess the issue is Excel file into test Suite cause that’s where I am trying to pass the data into variable
I’m pretty sure I could have used Excel just as easily in this case. There may be better ways of doing this, but you should be able to define the values you want passed into your test cases (set these variables up on each of the test cases in your suite). And on the Main script where you are calling all of these test cases you should be able to pass values in based on an excel file or the internal data feature.
Here’s a screenshot from one of my test cases where I’m calling many other test cases and passing in values to these. I have these values defined in the script calling all of these but I could read all of these in from an excel file just as easily. Might be easier to do that honestly, although if you work in the script view it’s pretty easy to edit and add values vs. the Manual view.
I see this is an old thread but it covers exactly what I have queries on!
I want to call a test case (A) from within another test case (B). I see that you are able to do so but were unable to reference more than one row from an excel sheet.
My situation is similar, I have:
Test Case A defines different routes through the application and is data-driven, using local variables.
Test Case B performs validation checks.
Test Case B would ideally sit in the Test Suite as the main test, as A is more like ‘shared steps’… however, unsure how to iterate through excel file on an embedded test case, as ‘variable binding’ in test suite only picks up the main test case.
The alternative is to make this one big test case but then that results in a lot of code duplication, as my test case A would expand into (multiple) test cases that all all have the same set of steps for navigating through different routes. Thanks and hopefully you remember the original post!
I honestly have not messed around with excel/data binding still. There are solutions out there for just reading from an excel file that may help you out (not using the data binding feature). Meaning you can setup an excel file (or setup multiple files, or define things differently on tabs) with whatever data you need to read in on the fly.
In this case you read the values you need from the excel file and feed them into your test case call.
If condition A read excel file x, grab values off of tab y call test case B with this data set else read tab z and call test case B with this data set.
Just spit balling here, not sure a solution like those above would work for you.
As an example I use on a regular basis, I try to setup re-usable test cases, say completing a search, in a way I have one test case and pass in different criteria depending on what it is I’m trying to validate. So all of my search fields are defined as a variable with a default value. If I need to search by a combination of criteria I just call my test case with values defined outside of the default values. For me at this point I’m just defining those values when I call the test case, I’m not feeding them in from a spreadsheet at this point. Something I will eventually move towards when the management of this data becomes a problem but for now I have not hit that threshold.
I don’t think this would solve @Hiral 's problem (or mine) unless I am misunderstanding - it seems like you are attempting to pass or query each value individually from the excel sheet explicitly, rather than let katalon loop over a spreadsheet until it gets to the bottom? Ie you are using excel as a lookup, more than a feed of data?
You may be right, I just put some thoughts together but honestly they may not match what is needed. I have not (yet) needed to loop over a spreadsheet, but I have used one of the plugins to read and write values to/from a spreadsheet so I know this could be used as a potential solution. With the plugin it’s certainly possible to get the number of rows in the spreadsheet and you could from there loop over the spreadsheet using some standard groovy syntax. If Katalon has a way to natively do this, then by all means that would probably be the way to go.
Thanks, due to proxy issues plugins are problematic at the moment but I think I’ve satisfied myself that a called test case cannot be easily passed variables from Excel (to iterate through a list) - it’s a bit outside my knowledge at the moment unfortunately. Cheers Dan