Using the debugger

One of the best ways to test code is through the debugger. This starts automatically when the code reaches a breakpoint, you are in the System Administrator security role, and your Windows account is in the local Windows user group called Microsoft AX Debugging Users Group.

To set up and run the test, follow these steps:

  1. Create suitable test data (vehicles, trailers, and trucks), including data to test false positives. For the first test, use a test case that should succeed.
  2. Open the ConFMSAppointmentVehicleHandler:: tmsAppointmentModifiedFieldEventHandler method.
  3. Set a breakpoint by selecting the TMSAppointment appointment = _args.getThis(); line, and press F9.

    Note

    A red dot will appear in the left-hand-side margin. A list of breakpoints can be seen by pressing Shift + F9.

  4. In the client, navigate to Transportation management | Common | Driver check-in and check-out.
  5. Click on Schedule an appointment.
  6. Enter a value (as per your test cases) in Tractor number, and tab out of the field.

    Note

    The debugger will open, highlighting the current line that is about to be executed. We are interested in watching the code execution and how the appointment record buffer is updated.

  7. The default layout will show a window in the bottom-left corner, with the Locals active tab. Note that the fieldId variable is 0 and the appointment record has <recid = 0>, as shown in this screenshot:
    Using the debugger

    Note

    <Recid = 0> means that the record has not been saved, which is also how we test whether a record was selected.

  8. Step over the next calls using F10 until the handler.run(); line, watching how the values are changing.
  9. The appointment will not appear to change because it is a new record, so expand this node to see that the TractorNumber field has changed to the value entered.
  10. On the handler.run(); line press F11 to step into the method.
  11. Step over (F10) the lines, and step into (F11) the this.handlerTractorNumber(); line.
  12. Verify that the getVehiceReferenceForType method succeeds, and then see that appointment.ConFMSVehicleTableTruck is set correctly.
  13. As you step out of the method, note that the field remains set.
  14. Step through tmsAppointmentModifiedFieldEventHandler using F11 until you are returned to the closing brace of TMSAppointment.modifiedField, and check the value of this.ConFMSVehicleTableTruck. The record was therefore passed by reference.

    Note

    When stepping through a post-event handler and once it is complete, we are returned to the event to which the handler is subscribed, at its closing brace.

  15. Continue your tests for each scenario using the debugger to trace the method flows. Should you wish to simply let the code run, press F5.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.67.70