Jump to content

Designing Tests


JKI

Recommended Posts

Unit tests should be designed around the following principles:

  • Unit tests should be simple - you don't want to spend time debugging tests
  • Unit tests should only test one thing (a "unit" of code) - unit tests should help you pinpoint problems so performing multiple tests within a unit test defeats this purpose
  • Unit tests should be independent of other unit tests - they should not depend on or affect other unit tests

To facilitate these principles, unit tests should be designed to work within a test harness. A test harness is a set of VIs called 'setUp.vi' and 'tearDown.vi' that run before and after each unit test method. The test harness facilitates keeping your code simple and preventing tests from interfering with each other by providing a place to initialize and cleanup the test data. Any task that is common to the test methods you need to run should be placed in the setUp.vi method. Any task that is needed to clean up the test environment should be put in tearDown.vi.

 

An important aspect of the unit test framework is how data is passed from the setUp to the testMethod and tearDown.vi. The data that is passed around are actually properties of the test and so these items should be placed in the test object private data. You can edit this data by opening the {Test}.ctl file.

 

Now that you've designed your new test, you should read some tips on how to easily debug your test.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.