Forum Discussion

rhu's avatar
rhu
Contributor
2 years ago

How to get a unique Logfile after each TestExecute run?

I have some tests where I start TestExecute and the Tests via commandline and I write a logfile to a directory like:
"C:\Program Files (x86)\SmartBear\TestExecute 15\x64\Bin\TestExecute.exe" "C:\mytest\test.pjs" /p:test /t:test /es:C:\Temp\TCLogs\LogT2.xml /SkipVisualizerData /NoSummary /DoNotShowLog /SilentMode /r /e

if executing  the log file will be written.
If executing again the logfile will be overwritten.
So how can I get different logfiles for each testrun (e.g. adding a timestamp at the end of the logfilname, so that the logfiles are unique) so that i can keep all logs for the testexecution?



  • 1st - thanks rraghvani for the idea to do the renaming with a "script".
    I am using an european date/time format like this:
    29.11.2022
    10:41:50,54

    there fore I added a line at the end of my batchfile where I rename the outputfile  and ad a timestamp like:
    ren C:\Temp\TCLogs\LogT2.xml LogT2_%date:.=_%-%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2%.xml

    and I get a filename like:
    LogT2_29_11_2022-10_41_50.xml

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I use a PowerShell script to run similar commands; and I pass in the date variable like this, "C:\Temp\TC_Automation_$timestamp", which TC then creates a folder with results.

     

     

     

     

  • rhu's avatar
    rhu
    Contributor

    1st - thanks rraghvani for the idea to do the renaming with a "script".
    I am using an european date/time format like this:
    29.11.2022
    10:41:50,54

    there fore I added a line at the end of my batchfile where I rename the outputfile  and ad a timestamp like:
    ren C:\Temp\TCLogs\LogT2.xml LogT2_%date:.=_%-%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2%.xml

    and I get a filename like:
    LogT2_29_11_2022-10_41_50.xml

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    A better approach is the change your command to include the timestamp, "C:\Program Files (x86)\SmartBear\TestExecute 15\x64\Bin\TestExecute.exe" "C:\mytest\test.pjs" /p:test /t:test /es:C:\Temp\TCLogs\LogT2.xml /SkipVisualizerData /NoSummary /DoNotShowLog /SilentMode /r /e. No need for rename.