How to modify the Results directory from a test?

Hi guys, one question please. I'd like to execute from one master at least 2 or more group of testcases which belong to other suites. I added those suites in the Tab of "Helpers" to include the reference. I could run them using RunWithNewResults. I want to produce one log file per script executed and gather all those results in one single Result directory, the directory from the master that is calling all the other scripts from the other suites. I tried executing my tests but I get the log files separated, each of them in their Results folder from their individual suites.
Is there a way to change the Results directory during the execution using RunWithNewResults?

I did not find any explanation about this, Eggplant tutorial says only you can refer to the script and its parameters:

RunWithNewResults scriptName, parameters

I also saw in the tutorial there is one command that says setOption with which I can modify Global variables.... but how do I modify the Results directory from the test that I will execute?
I think my solution could be to overwrite the value of a Results default variable, but I am not sure if this is possible and what variable.

Please let me know, how can I modify the Results folder using RunWithNewResults

PS: I saw this can be modified when you execute from command line.

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    You can change where all of the results are written, but that's a global setting and can't be set from a script. There's really nothing you can set that will give you what you want. The one thing you could do if you are using RunWithNewResults is to follow each run with code like this:
    move file logFile of the last item of ScriptResults("<myScript>") to "path/to/someDir/<myScriptLog>"
    
    Where "<myScript>" is the name of the last script you ran and <myScriptLog> is a unique name for that log file; you will need to specify a name since all of the result files are called simply "LogFile.txt". You will also need to decide whether you want to move the results or just copy them.
  • Thanks for the answer. I tried it an it worked.
    Guys, I wanted to execute from a single masterscript test cases from different suites and then use html report generated as a view from my entire execution.
    That's why I wanted to have all reports in a single folder, the Results folder from the master that calls the other. The result I get is an HTML report with only one line of execution from the name of my master and
    if it was passed or failed.
    Report looks like:
    Master User PASSED ran at 14:10

    Instead, I wanted to get a report that said:
    Delete User PASSED ran at 14:10
    Delete User PASSED ran at 14:12
    Add User PASSED ran at 14:14


    My code looks like this:
    // Execute test DeleteUser for User Id = 4
    	RunWithNewResults testDeleteUser, "userId4"	
    	put the result into Outcome
    	put testScript & ":" && status of Outcome && Return after currentReport
    	move file logFile of the last item of ScriptResults("DeleteUser") to suitePath & "Results/" & currentExecution  & "/deleteUser" & today & the seconds & ".txt"	
    
    // Execute test DeleteUser for User Id = 7
    	RunWithNewResults testDeleteUser, "userId7"	
    	put the result into Outcome
    	put testScript & ":" && status of Outcome && Return after currentReport
    	move file logFile of the last item of ScriptResults("DeleteUser") to suitePath & "Results/" & currentExecution  & "/deleteUser" & today & the seconds & ".txt"	
    
    // Execute test AddUser for User Id = 10
    	RunWithNewResults testDeleteUser, "userId10", "John", "Smith"	
    	put the result into Outcome
    	put testScript & ":" && status of Outcome && Return after currentReport
    	move file logFile of the last item of ScriptResults("DeleteUser") to suitePath & "Results/" & currentExecution  & "/addUser" & today & the seconds & ".txt"	
    
    HTMLReport suitePath, suiteName, reportFolder
    

    I dont understand what I could be doing wrong and where the line reports are generated. I already tried with a master inside the suite from the tests I want to run and I could get an html report with a line per execution. This case is different, though. I want to execute from a master test cases from different suites. What line can I modify or how can I get what I meant?

    Thanks beforehand! :D
  • I dont understand how the following variables work (what's their role):
    the result
    Outcome
    testScript
    currentReport

    I wonder because I copy/pasted a sample code from a forum about HTML report and it worked in the case I had to execute several tests from the same suite. It did not work for executing tests from different suites....
  • Hi, in the solution you provided you say:
    move file logFile of the last item of ScriptResults("<myScript>") to "path/to/someDir/<myScriptLog>"
    

    This code moves the txt file, but it does not move the result from the execution, the file .success or .failed

    How can I move that file too? maybe that's why the HTML report does not generate several lines in the report, per test executed?

    I need to move those files before executing HTMLReport?
  • EggplantMattEggplantMatt ForumAdmin admin
    No code that we've posted would use the .success or .failure files. They're hidden files and most people wouldn't even know they were there. I think the code that you're referring to just looks at one of the fields in the last line of the logfile to determine the outcome of the script.
  • JonathanOSXJonathanOSX ForumAdmin admin
    My advice would be to move or copy the entire FOLDER (instead of just the logFile.
    To get the success file and any other files (like the ScreenError.tiff) that might be generated.
  • Thanks for your suggestion, how can I move the entire folder to another place?
  • JonathanOSXJonathanOSX ForumAdmin admin
    From the SenseTalk Reference manual, you can copy a folder with this syntax:
    copy folder planFolder to "~/Documents"
    
    To get the folder of a file you can just say the folder of file, so the whole sequence for you might look like:
    set currentLog to logFile of the last item of scriptResults("<myScript>")
    set logFolder to the folder of file currentLog
    copy folder logFolder to "/tmp"
    
  • Thanks for the explanation Jonathan, after your explanation it looks more clear. I think the best solution for my requirement would be to move the entire folder of the script, instead of each folder. I mean, if I have my script testOne, I'd like to copy folder testOne.suite/Results/testOne, instead of copying each folder generated inside testOne.suite/Results/testOne.

    How can I refer to the folder of the script that just ran?
    I tried the following:
    put the folder of ScriptResults("TestOne") into ResultFolder
    move folder ResultFolder to "/tmp"
    

    It throws an exception that says STFile System Exception failed to move C:/Documents and settings/myuser/My Documents/logs....etc

    How can I refer to Results/testOne folder?

    Regards,

    Rommy
  • EggplantMattEggplantMatt ForumAdmin admin
    There are at least two ways of doing this:
    move folder (the folder of the folder of logfile of the last item of scriptResults("TestOne")) to "/tmp"
    
    or
    move folder (the folder of my folder & "Results/TestOne") to "/tmp"
    
    Both examples assume you are running your script from the same suite as the script you are referencing ("TestOne").
Sign In or Register to comment.