Best way to handle bat execution within TC
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just for clarification, are you running a batch file from TC in TestedApps? What does your batch file do?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That was one method I tried. I also tried running from a script. The script method wasn't very clean and also wasn't working for other coworkers/stopped working for me. I thought maybe the TestedApps approach would be better.
The bat does a bunch of things but namely runs SQL commands and ReadyAPI dataloads into the test env
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Within your batch file, you need something like,
START /B /WAIT
Where, /B to stay in the same process and /WAIT to wait until the command has finished.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try the solution that I provided?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Couldn't get it to work
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should have mentioned it at the time 🙄
