Creating DQMH Unit Tests
DQMH 4.0 added a new productivity tool to create Unit Tests The developer uses the Test Module API.vi 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 API.vi 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 Tests The following video shows how to implement Test Driven Development using 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:
-
Create the Request or Request and wait for Reply event, save all, do not implement the code just yet.
-
Create the Broadcast event if necessary, save all, do not implement the code just yet.
-
Create new Unit Tests
-
Go to Tools>DQMH Consortium>DQMH>Testing Tools>New DQMH Unit Test…
-
Select DQMH module for which you wish to create the unit test.
-
Select the Request event you want to make a unit test for.
-
Click the OK button and the unit test will be created.
-
The New DQMH Unit Test adds the Unit Tests virtual folder to your project.
-
If this is the first Unit Test created for this Module, then the New DQMH Unit Test utility creates three VIs
-
<Module Name> setup.vi
-
<Module Name> teardown.vi
-
Test - <Module Name> - <Request Name> <number>.vi
-
-
If this is not the first Unit Test for this Module, then the New DQMH Unit Test utility creates only
-
Test - <Module Name> - <Request Name> <number>.vi
-
-
There can be multiple unit tests for each Request event. |
-
Implement the Unit Test by following the instructions given by the #CodeNeeded bookmarks on the newly created test.
-
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
-
If the developer has not implemented the code under test yet, the unit test should fail.
-
Implement the event code needed in the DQMH Module Main and in the Test Module API.vi.
-
Verify that the code works via the Test Module API.vi. Then run the unit tests and verify that those test pass as well.