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");
WebUI.callTestCase(findTestCase('Create new Person'), [:], FailureHandling.STOP_ON_FAILURE)
WebUI.click(findTestObject('Object Repository/Page_Person Profile (PP000)/a_Case Profile'))
System.out.println("people are created");
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.
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.
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.
On startup, my test script will read the JSON file; parse the JSON; convert it into the GlobalVariable.Persons.
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.
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.
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