Forum Discussion

ebodien's avatar
ebodien
Contributor
14 years ago
Solved

OnStep Event

I'm attempting to create what I thought would be a simple event to post the Notes field of a Manual Test to the Log on step success.  Based on the help files I attempted the following: Sub Gene...
  • AlexanderM's avatar
    14 years ago

    Hi Eero,





    There are 2 ways to do this, depending on the way you run manual tests:





    1. Add manual tests to the Test Items collection and run them from the collection. In this case, you can use the following approach:



    Sub GeneralEvents_OnStepSuccess(Sender, StepParams)

      Dim currentManualTestName, currentStep 

                            

      currentManualTestName = Split(Project.TestItems.Current.ElementToBeRun.Caption, " - ")(1)

      Set currentStep = Eval(currentManualTestName).GetStepInfo(StepParams.StepID)

      Call Log.Message("The " & currentStep.GetCaption() & " step data", "Notes: " & currentStep.GetNotes())

    End Sub







    2. Run manual tests from script and use a global variable to hold a manual test's name. If you use this approach, your script can be as follows:







    Dim currentManualTest





    Sub RunManualTest

      Dim manualTestName

      

      manualTestName = "ManualTest1"

      On Error Resume Next

      Err.Clear()

      Set currentManualTest = Eval(manualTestName)

      If 0 <> Err.Number Then

        Log.Error("The " & manualTestName & " manual test was not found")

        On Error Goto 0

        Exit Sub

      End If

      currentManualTest.Start()

    End Sub





    Sub GeneralEvents_OnStepSuccess(Sender, StepParams)

      Dim currentStep 

                            

      Set currentStep = currentManualTest.GetStepInfo(StepParams.StepID)

      Call Log.Message("The " & currentStep.GetCaption() & " step data", "Notes: " & currentStep.GetNotes())

    End Sub







    I hope this helps.