Hi guy,
Right now, i have a test data file created from a csv file, that file may needs frequent updates, since the information contained it’s based on a network folder file structure.
My question is. ¿Is there a way to execute a script/something, when a project loads or when click on Run/Debug? So, I can verify the csv file is up to date, so if not, update it so the data file can be as well up to date.
Regards and thanks!
1 Like
The Test Listener would help you.
1. Use Test Listeners
for Pre-Execution Tasks (Before Test Runs)
2. Use Global Variables
with Static Initialization (On Project Load)
3. Use a Pre-Execution Script
in CI/CD Pipelines
For automated runs (e.g., Jenkins, GitLab CI), add a pre-build step to update the CSV file:
Example (Jenkins):
bash
#!/bin/bash
# Check if network CSV is newer than local CSV
if [ "\\\\network\\path\\data.csv" -nt "Data Files/local_data.csv" ]; then
cp "\\\\network\\path\\data.csv" "Data Files/local_data.csv"
fi
4. Use Katalon’s Profile
Scripts
Leverage Custom Keywords called at the start of every test case:
Steps:
- Create a keyword (e.g.,
UpdateCSVKeyword
):
groovy
class UpdateCSVKeyword {
@Keyword
def checkAndUpdateCSV() {
// Your CSV update logic here
}
}
- Call it in
SetUp
method of test cases:
groovy
@BeforeTestCase
def setUp() {
CustomKeywords.'UpdateCSVKeyword.checkAndUpdateCSV'()
}
I’ve tried the hooks but modifying the file becomes impossible since it throws an exception saying the file is being used by another process, but i’ll take a look into the profile scripts, i didn’t know about those.
Resolved with a custom plugin, using the tutorial one as base, I can execute my process every time the plugin loads that’s basically every time I load any project and that did the trick, still thanks for the suggestions @dineshh and @kazurayam
Regards to all!