Constrain Execution Step

 

User's Requirement

 

A Step must be executed only if it is the 1st one or if the previuos step status is "Passed" or "Failed".

 

Proposed Solution

 

To achieve this requirement we could work on the Enabled property of the Actions analyzing the status of the previous step or enabling the Actions if the selected step is the 1st.

 

For previous or next step we refer on the order property of the steps ("ST_ORDER").


_______________________________________________________________________

 

Implementation on the Product

 

Most of the logic is inside the Sub Step_MoveTo that analyze the selected step. The first thing that is done when the sub is invoked is to disabled some actions and then they could be enabled if:

- the selected step is the 1st

   or

- the previous step status is valid (passed/failed)

 

These are the actions on which we operate:

 

- Pass Selected: act_pass_selected

- Fail Selected: act_fail_selected

- Add Step: act_add_step

- Delete Step: act_del

- Add Attachment: act_attach

- New Defect: act_add_bug

 

and also:

- Pin OnTop: act_pin_unpin

- Back View: act_back

- Mini Step: act_ministeps

 

This is the implemented code:

 

1. Common Module - ActionCanExecute Function

'this is to call the ActionCanExecute of the Manual Runner Module

if ActiveModule = "ManualRun" then
    ActionCanExecute = ManualRun_ActionCanExecute(ActionName)
 end if

 

2. Manual Runner - ManualRun_ActionCanExecute

 

Dim res
res = True

 

  Select Case ActionName

         Case "act_add_step", "act_del", "act_pin_unpin", "act_back", "act_ministeps":

                   res = False  'These action will not be executed, never.

  End Select

 

 ManualRun_ActionCanExecute = res

 

 

3. Manual Runner Module - Sub Step_MoveTo

 

  Dim MyRun 

  Set MyRun  = TDConnection.RunFactory.Item(Run_Fields("RN_RUN_ID").Value)
 

  'disabled all buttons

  Actions.Action("act_add_step").Enabled = False
  Actions.Action("act_del").Enabled = False
  Actions.Action("act_pin_unpin").Enabled = False
  Actions.Action("act_back").Enabled = False
  Actions.Action("act_ministeps").Enabled = False
  Actions.Action("act_pass_selected").Enabled = False
  Actions.Action("act_fail_selected").Enabled = False
  Actions.Action("act_attach").Enabled = False
  Actions.Action("act_add_bug").Enabled = False

 

  'disabled all fields

  for k=1 to Step_Fields.Count
      Step_Fields.FieldById(k).IsReadOnly=True
  next

 

  'Enabled only buttons to passed, failed, add attachments and add bug

  'if the step selected is te 1st one or another that can be executed

  'because the previous step has a valid (passed/failed) status

 

  'Verify the order number of the step selected

 

  Dim nr_Ord
  Dim thisStep

 

  set thisStep = MyRun.StepFactory.Item(Step_Fields.Field("ST_ID").Value)
  nr_Ord = thisStep.Field("ST_STEP_ORDER")

 

  Select Case nr_Ord

         'if the step is the 1st one I enable the Actions

         Case 1: Step_EnableActions

         'otherwise I need to verify the previous step status

         Case else:
                 Step_VerifyPrevStepStatus(thisStep)

  End Select

 

 

4. Manual Runner Module - Step_EnableActions (this is a new Sub to insert in the module)

 

Sub Step_EnableActions
    On Error Resume Next

 

    Actions.Action("act_pass_selected").Enabled = True
    Actions.Action("act_fail_selected").Enabled = True
    Actions.Action("act_attach").Enabled = True
    Actions.Action("act_add_bug").Enabled = True

 

    'Here I enable the only Actual Result Field. 

    'It is also possible to enable all fields.

    Step_Fields.Field("ST_ACTUAL").IsReadOnly = False

 

    On Error Goto 0
End Sub

 

 

5. Manual Runner Module - Step_VerifyPrevStepStatus (this is another new Sub to insert in the module)

 

Sub Step_VerifyPrevStepStatus(myStep)
    On Error Resume Next

 

    Dim nr_Ord_Prev           'the previous order number
    Dim Run_StepList          'the step list of the run object
    Dim myPrevStep            'the previous step object


    nr_Ord_Prev = myStep.Field("ST_STEP_ORDER") - 1


    set Run_StepList =  TDConnection.RunFactory.Item(Run_Fields("RN_RUN_ID").Value).StepFactory.NewList("")

 

    'for cycle to anayze all the steps

    for each el_St in Run_StepList

        if el_St.Field("ST_STEP_ORDER") = nr_Ord_Prev then
           'This is the prev step
           set myPrevStep = el_St


           'I execute a refresh of the status.

           'NOTE: These next 2 instructions assure you that  the status is updated
           myPrevStep.Post
           myPrevStep.Refresh

 

           'Now I verify if the status is Passed or Failed
           if myPrevStep.Status = "Passed" Or _
              myPrevStep.Status = "Failed" then

              'Enabled the action for the Current Step (myStep)
              Step_EnableActions

           end if

        end if
    next

    On Error Goto 0
End Sub

 

 

Pag:  <<    <