Creating DQMH Unit Tests

DQMH 4.0 added a new productivity tool to create Unit Tests The developer uses the Test Module to interact with the DQMH Public API and test it. This is very useful to verify that the DQMH module is working as expected. The developer can use the Test Module as a sniffer to verify that the module is working as expected when the application is running. While this is useful, it does not lend itself for automatic testing. If the developer wants to implement Test Driven Development (TDD), they would need to create their unit tests before they implement their Request events and Broadcast events.

This video shows how to create a DQMH Unit Test for an existing event.

Create DQMH Unit Test

Create DQMH Unit Tests The following video shows how to implement Test Driven Development using DQMH Unit Tests.

TDD with DQMH Unit Tests

Create DQMH Unit Tests for TDD NOTE: Developers do not need to be following TDD to use this feature. Developers could create Unit Tests for existing events by starting on step 3 on the list below.

The steps to introduce test-driven development to DQMH are:

  1. Create the Request or Request and wait for Reply event, save all, do not implement the code just yet.

  2. Create the Broadcast event if necessary, save all, do not implement the code just yet.

  3. Create new Unit Tests

    1. Go to Tools>DQMH Consortium>DQMH>Testing Tools>New DQMH Unit Test…

    2. Select DQMH module for which you wish to create the unit test.

    3. Select the Request event you want to make a unit test for.

    4. Click the OK button and the unit test will be created.

    5. The New DQMH Unit Test adds the Unit Tests virtual folder to your project.

    6. If this is the first Unit Test created for this Module, then the New DQMH Unit Test utility creates three VIs

      • <Module Name>

      • <Module Name>

      • Test - <Module Name> - <Request Name> <number>.vi

    7. If this is not the first Unit Test for this Module, then the New DQMH Unit Test utility creates only

      1. Test - <Module Name> - <Request Name> <number>.vi

There can be multiple unit tests for each Request event.
  1. Implement the Unit Test by following the instructions given by the #CodeNeeded bookmarks on the newly created test.

  2. The developer can choose their Unit Testing tool to run their new unit test. The New DQMH Unit Test utility is agnostic. Go to the help section for your tool

  3. If the developer has not implemented the code under test yet, the unit test should fail.

  4. Implement the event code needed in the DQMH Module Main and in the Test Module

  5. Verify that the code works via the Test Module Then run the unit tests and verify that those test pass as well.