Forum Discussion

user_j_e's avatar
user_j_e
Occasional Contributor
14 years ago

OnStopTest and TestItems

I am trying to get the log pass/fail status of the last item that ran.  I am using the OnStopTest event handler but it seems to run the method at the end of the TestItem and not after the TestItem is finished and the pass/fail status is logged. Is there a way to get the pass/fail status of the last TestItem that ran?   I could add another TestItem at the end, just wondering if there is a better way.

Thanks

6 Replies


  • Hi,





    OnStopTest is generated after the execution is finished and a log is created. But the LogResults object that is used to retrieve the status does not provide access to the current test log. This is because the test log contents are formed during the test execution, and the log is only added to the list of project logs after the test run is finished. So, you need to run the project and then run the routine that contains the following code:







    TotalLogNumber = Project.Logs.LogItemsCount

    Set LastProjectLogCreated = Project.Logs.LogItem(TotalLogNumber - 1)

    If LastProjectLogCreated.ChildCount > 0 Then

      Log.Message(LastProjectLogCreated.Child(LastProjectLogCreated.ChildCount - 1).Status)

    End If







    For more information, refer to the Scripting Access to the Test Log Contents help topic.
  • user_j_e's avatar
    user_j_e
    Occasional Contributor
    I am trying to run the test unit from the TestExeucte command line because I want to run a sub set of tests to verify my environment before I run the entire suite. 



    Is there a way to run  a group of tests?  For example if I were to create a group in the TestItems , is there a way to run just that group of tests from the command line?   I realize I could modify the TestItems and save it somewhere else and copy the file back  and forth when I want to run my verification tests, but it would become problematic when something else in the mds file changes.



    Thanks
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi,



    For TC8 it is possible to specify from the command line the test items to be executed (see the "Command line" help topic for more details). For the TC versions prior to v.8 this is not possible and must be implemented via additional coding.

  • Hi,





    Currently, test items' groups cannot be run from the command line. We have suggestions to implement an ability to run specific test items and test items' groups in our database. Your request has increased their ratings.





    As an alternative, you can check the needed test items manually and use the /p switch that allows you to run all the enabled test items of the specified project:

    "C:\Program Files\Automated QA\TestExecute 8\Bin\TestExecute.exe" "C:\My Projects\MySuite.pjs" /r /p:MyProj





    For more information, refer to the TestExecute Command Line help topic.
  • user_j_e's avatar
    user_j_e
    Occasional Contributor
    If I have  a suite setup to run three test items.



    I have a an onStop event handler that is calling a unit function called logit().



    function logit()

    {

    Log.Message("count:"      + Project.Logs.LogItemsCount);

    Log.Message("childcount;" + Project.Logs.LogItem(0).ChildCount);

    }



    If I try to run the suite using TestExecute it will thow the error "parameter incorrect".



    It doesn't appear that TestExecute have access to the Project.Logs.LogItem(0) when the suite is running.



    I am assuming that the LogItem(0) does not change as
    Project.Logs.LogItemsCount  is always zero when it iterates though the
    test items. 

  • Hi,





    We have already replied to you via e-mail. Here is a copy:

    The LogResults object (returned by Project.Logs) provides access to project logs listed in the Project Explorer and does not provide access to the current test log. This is because the test log contents are formed during the test execution, and the log is added to the list of project logs only after the test run is finished. For more information, refer to the LogResults Object help topic.