Restore a database in Katalon

Is there any way to trigger a database restoration after a test case has been completely executed, I’m trying to use a custom keyword, but no luck as yet. I keep getting the following: [ERROR] - java.io.IOException: Cannot run program “sh”: CreateProcess error=2, The system cannot find the file specified.

This is how my custom keyword looks:

@Keyword

restoreDB(){
def script = [‘sh’, ‘-c’, “mysql db_0002_data < C:/Documents/dumps/Dump20180907.sql”].execute()
}

you have shell on windows?

I’ve been using shell commands through git bash, does that count?

it is an linux executor or a windows one? depending on that you have to use a shell (bash) script or an PowerShell script

sh stands for (ba)sh, aka linux script

as a rule of thumb:
any command you want to execute using katalons groovy execute, must be executable from console - in this case cmd.exe …

2 Likes

Thanks Andrej, I did a similar thing in another framework and thought it would work here. I’m not getting that error now but still not working but I should be able to figure this one out, thanks again

1 Like

welcome