How to record start time and stop time for my suite?

Hi all,

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.

What is the best way to do it?

Thanks in advance.

CEQA

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    I'd probably just write the time out to a file at the beginning of the first script and the end of the next to the last script:
    put "Start time:" && now & return into file "path/to/my/file"
    put "End time:" && now after file "path/to/my/file"
    
    Then I'd have a final script that just read those values out of the file and sends the e-mail.

    Note: The "now" keyword is going to return a value that contains both the date and the time, in a format like this:
    2011-07-20 10:59:44 -0600
    
    You can specify a different format for the value that your script writes out.
  • CEQACEQA Member
    Thanks.

    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

    SendMail(to: emailaddress, from: "emailaddress", subject: "Automation result", body: "myline1 & return &&myline2 & return &&myline3)

    It works well.

    But if I want to add the failed test cases info into my result file "qa1", what is the best way to do it?

    Format like following:

    Failed test cases:
    test1
    test5
    etc.

    Thanks in advance.

    CEQA
  • EggplantMattEggplantMatt ForumAdmin admin
    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.
  • CEQACEQA Member
    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"

    CEQA
  • EggplantMattEggplantMatt ForumAdmin admin
    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
    
  • CEQACEQA Member
    Thanks.

    CEQA
Sign In or Register to comment.