Setting the status of a script to fail

I'm having some trouble setting the status of my script to "Failure" after running it from a master script so something like this:
Run "abcd"
put the result into Global outcome
if Global pstatus is "Failure" then
         Set the status of Global outcome to "Failure"
end if

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    So you want to run script B from script A, and then make Script B log as a failure?

    1. Can I ask why?
    2. Using the Run command, script B won't have a status of its own; it's executed as part of the calling script. If you want it to have its own results and status, you need to use the RunWithNewResults command.
    3. The status of the script is written to a file. Once the script has finished executing, the only way to change its status is by overwriting the value in the file, which can be done, but it's not a one step process.

    Please let me know if I've misunderstood the question.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    It's true that you can't really change the success status of a script after it has run. On the other hand, if you want to change the status of a running script to failure before it finishes, you can simply execute a LogError command, which will force it to register as a failure.

    So for example if you use a master script to run several other tests using RunWithNewResults and want your master script to show as a failure if any of the other tests fail, then you could do something like this:
    RunWithNewResults someTestScript
    put the result into outcome
    
    if outcome.status is "Failure" then LogError "Test Failed: " & someTestScript
    
  • I was thanks that worked great. The reason i needed this is for my custom logging Im doing a lot of this because with our build server the results of these tests need to be up in specific formats and the logging itself to put out some custom messages without all the filler of the default logging. I custom wrote a few scripts To output new text log files, XML log files and Excel log files is specific folder and network locations.
Sign In or Register to comment.