Can a Katalon test call another Katalon test that uses variables from an excel file?

I have an automation test that creates a n people that are loaded in an excel file. (Create new Person)

Now I’m trying to create a ‘New Case Test’ that calls ‘Create new Person’ to get the people and add them into the case. However at runtime the New Case Test successfully calls the ‘Create new Person’ but the attribution is not being pulled from the excel file.

If I run the Create new Person solo, it work just fine. It pulls the data from the excel file and loads the people

Here’s the ‘New Case Test’

WebUI.callTestCase(findTestCase('Login'), [:], FailureHandling.STOP_ON_FAILURE)

System.out.println("we are logged in");'Object Repository/Page_Landing/a_Area'))

//Create People
WebUI.callTestCase(findTestCase('Create new Person'), [:], FailureHandling.STOP_ON_FAILURE)'Object Repository/Page_Person Profile (PP000)/a_Case Profile'))

System.out.println("people are created");

When you call the Excel file, do you “load” the Persons into variables that can “cross” from one Test Case to another either as static or global?

I actually loaded them from the same excel file… Person Id, Person Name Person DOB etc… so I load in the name and dob… then when the test is over I write out the person Id

I may not understand your concern then, but I create a Customer, then write the Customer information out to Excel, then the next Test Case reads the Customer information from Excel and I proceed with my testing. If I call another Test Case from within the main one or as a Test Suite, I read the Customer information into Global Variables so the information is “intact” throughout the Test Cases of the Test Suite.

If I run the test case ‘Create new Person’ it will correctly read the values from excel and create the people and then update the file with the new id.

If I call ‘Create new Person’ test case from within another test, it cannot read the values from the excel file.

Do you fis.close() and fos.close() your connection to Excel in your code? Do you open the Excel spreadsheet to “review” your Person’s information (creates a lock on the spreadsheet)? Do you use the same “tester” to run both tests (file permissions)?

Anyways, to answer your original question, yes, you can write out data to Excel and read data into your next TC but you may have to organize it some.

It isn’t an issue of another test accessing the file. The same test ‘Create new Person’ can access the file when called directly, but if another test calls ‘Create new Person’ it cannot access the data.

Do you put your spreadsheets in the Data folder of your project? Can you show us the pathway you are using to access the spreadsheet?

Here is a sample that I found just down the forum list from yours.

My test uses a data file and then there are variables bound to that file.

Maybe my approach is wrong - I’m trying to break each test by a user’s typical behavior. Then group them where it makes the most sense. ie common routines etc.

rather excel, can we use json/yaml for resource files?

What do you mean by this sentence?

On which screen did you see and found “the attribution is not being pulled from the exel file”?

Any screenshot?

What do you expect to see and what did you actually see?

Something like this?

It seems that you expect that as soon as a new record is inserted into an Excel sheet the record will be displayed in the “Data Files” pane immediately and automatically.

I don’t think it works as such.

Katalon Studio’s “Data-driven testing” feature has an implicit design assumption: users will refer to Excel data as read-only. Test Cases will use Excel data as input only, will never make output into the Excel data.

I guess, you naively expect the Excel file is dynamically reloaded by Katalon whenever the file is updated somehow. That is not the case.

The Excel file specified as the “Data Files” source is loaded only once when the test started. The Excel file won’t be reloaded even if the Excel file was updated by your scripts.

In case that the “Data-driven testing” feature of Katalon Studio does not fulfill your requirement, you need to invent a solution how to manage the data of “Persons” for your self.

If I were to make a Test Case that inserts data record during a run, and want let other Test Cases to use the updated data set, I would design my test as follows.

  1. I will make a GlobalVariable named GlobalVariable.Persons of type List<Map<String, String>>
  2. I will manually make a JSON file like
    "GENERATED ID": "1871703", "LAST NAME": "Excel05", "FIRST NAME": "MOM", "DOB": "12/15/80", "GENDER":"F", "ROW ID": "1"
    "GENERATED ID": ....
  1. On startup, my test script will read the JSON file; parse the JSON; convert it into the GlobalVariable.Persons.
  2. My test script will work on the GlobalVariable.Persons (add/modify/delete Person records). My test script will NOT serialize the variable into file during the processing.
  3. The other Test Cases will refer the GlobalVariable.Persons as needed. These scripts can refer to the updates into the GlobalVariable.Persons by other Test Cases. Thse script do not read/write the external file. No need to make I/O to the file during the processing.
  4. On closing, my test script will serialize the GlobalVariable.Persons into a JSON text, and write it into an external file. The file might be the same one as the script read in on the starup; or it could be a new one.

Your code should refer to a GlobalVariable of type List<Map<String,String>> to share the data while you keep full accessiblity (add/modify/delete) to the data set.

Excel or JSON — the format of the file as external persistence is not really important. Either will do. Up to your preference.

If you want to read and write a Excel file in Katalon Test Case. So please refer to the following post

The Generated ID is the only populated field. This excel spreadsheet is supplying the data that I was injecting into the test. So in this example above I’m adding 3 new people.