I have a suite includes lots of scripts. Usually I put all my scripts into Schedule to run. I want to record the start time and stop time for my suite (not for one script file)
I also want to send an email after running through my suite. This email body should include start and stop time.
I put the following into the first script of my suite:
put “The Automation Run at:” && the long date && return && “Start Time:” && the long time & return into file “qa1”
Also put the rest into last script of my suite:
put " End Time:" && the long time after file “qa1”
put line 1 of file “qa1” as data into myline1
put line 2 of file “qa1” as data into myline2
put line 3 of file “qa1” as data into myline3
The only good way to do this is to run your scripts from a master script using the RunWithNewResults command. If you do that then you can check the result of each script as it’s run and compile a list of scripts that fail. But if you’re running a Schedule then it would difficult to figure out. It’s not impossible, but there’s no built in mechanism for it and it would be hard to do it dynamically so that changes to your schedule were automatically accounted for. You could, for example, scan the Results directory for folders that were modified since the start of your scheduled run, get the name of the corresponding script, and then use the ScriptResults function to get the result of the last run of that script. Using the code you’ve already written, you’re storing the start time of the first script, so you already have the data to base the timestamp comparison on.
Yes. I did think about run my scripts from a master script using the RunwithnewResults command. But I think if someone uses different method to solve this problem. Thank you very much.
By the way, I have following master script to run and want to write failed result into my qa1 file, what should I do?
runwithnewResults test1
if the status of the result is not equal to Success
put the status of the result && “of test1” after file “qa1”
End if
runwithnewResults test2
if the status of the result is not equal to Success
put the status of the result &&“of test2” after file “qa1”
End if
if test1 somehow failed, in my qa1 file, should I get “failed message” + “of test1”, but I only see “of test1”
You can’t refer to “the result” in two consecutive lines, since the second “the result” in the third line is actually the result of executing the second line. If you want to refer to “the result” of the script execution in consecutive lines, then you need to store that value:
runwithnewResults test1
put the status of the result into outcome
if outcome is not equal to Success
put outcome && "of test1" after file "qa1"
End if
Although, since you’re only executing the if block if the script fails, you could just say:
runwithnewResults test1
if the status of the result is not equal to Success
put "test1 failed" after file "qa1"
End if