Changeset 51 for trunk

Show
Ignore:
Timestamp:
04/09/09 13:38:47 (3 years ago)
Author:
mgalloy
Message:

Have a draft of the using mgunit document.

Location:
trunk/mgunit/docs
Files:
2 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/mgunit/docs/using-mgunit.txt

    r50 r51  
    22------------ 
    33 
    4 MGunit is a unit testing framework modeled on other unit testing frameworks such as JUnit. The goal is to allow easy creation and reporting of results of tests, but still allow for all needed flexibility. Simple naming conventions replace formal creation of hierarchies and specification of tests. This allows test suites to be created with a minimum of code beyond the actual code of the tests themselves. 
     4MGunit is a unit testing framework modeled on other unit testing frameworks such as JUnit. The goal is to allow easy creation and reporting of results of tests, while still allowing for many different testing situations. Simple naming conventions replace formal creation of hierarchies and specification of tests. This allows test suites to be created with a minimum of code beyond the actual code of the tests themselves. 
    55 
    66 
     
    133133-------- 
    134134 
    135 Setup/teardown. 
     135The setup and teardown methods of a test case class are executed before and after each individual test. By default, they are empty, but subclasses of MGutTestCase can override them to do any common setup/teardown tasks. Any data to be stored from the setup is normally saved as an instance variable of the test case class so that it can be accessed by the test and the teardown method. 
    136136 
    137 Common checks i.e. memory leaks 
     137Pointer and object memory leaks can be tested for using fixtures by comparing the number of current pointers and objects during setup and teardown. 
    138138 
    139139 
     
    141141------------ 
    142142 
    143 Compound, log, HTML 
     143Results can be sent to a log file with the FILENAME keyword:: 
    144144 
    145 Results can be sent to a log file with the LOG_FILE: 
    146 IDL> mgunit, 'findgentest', log_file='results.log' 
     145  IDL> mgunit, 'indgen_uts', filename='test-results.log' 
    147146 
    148 This should produce the output: 
    149 Starting test suite MGTESTSUITE (1 test case, 4 tests) 
    150    Starting FINDGENTEST (4 tests) 
    151       TEST1: failed "Wrong number of elements" 
    152       TEST2: passed 
    153       TEST3: passed 
    154       TEST4: failed "Type conversion error: Unable to convert..." 
    155       Results: 2 / 4 tests passed 
    156    Results: 2 / 4 tests passed 
    157     
     147This will send the normal output to the results.log file. 
     148 
     149HTML output can also be created with the boolean HTML keyword to the MGUNIT routine. Generally, the FILENAME keyword is used in conjunction with this option:: 
     150 
     151  IDL> mgunit, 'indgen_uts', filename='test-results.html', /html 
     152 
    158153 
    159154Miscellaneous 
     
    166161---- 
    167162 
    168 Subclass a subclass of MGutTestCase. 
     163It can be useful to create a subclass of MGutTestCase for a project so that each test case in the project inherits from that class instead of directly from MGutTestCase. This case can do work common to all the tests i.e. find the location of test data, have common setup/teardown methods, etc. 
    169164 
     165The NTESTS, NPASS, and NFAIL keywords to the MGUNIT routine output the appropriate values. These can be handy for automated scripts i.e. sending email if any test fails, etc. 
     166