Best way to handle bat execution within TC
I have several use cases where executing a batch script before executing TC tests would be very beneficial.
This seems simple but the solutions I've tried have started the bat file and then TC marks the task as completed prompting the first test in the suite to start before the bat is actually done executing.
Does anyone have any solutions for this?
Can I pass in some command line parameter in TestedApps to keep the bat open until it finishes?
My solution for this was just writing a custom script that runs in the execution plan:
function runBatchFile(batchFilePath) {
try {
var process = Sys.OleObject("WScript.Shell");
process.Run('cmd.exe /C "' + batchFilePath + '"', 1, true);
while (process.Status == 0) {
Delay(100);
}
Log.Message("Batch file executed")
}
catch (e) {
Log.Error("An error occurred while running the batch file: " + e.message);
}
}var batchFilePath = "D:\\SmokeTestCleanup.bat";
runBatchFile(batchFilePath);