- Timestamp:
- 04/09/09 13:38:47 (3 years ago)
- Location:
- trunk/mgunit/docs
- Files:
-
- 2 added
- 1 modified
-
test-results.html (added)
-
test-results.log (added)
-
using-mgunit.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mgunit/docs/using-mgunit.txt
r50 r51 2 2 ------------ 3 3 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.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, 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. 5 5 6 6 … … 133 133 -------- 134 134 135 Setup/teardown.135 The 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. 136 136 137 Common checks i.e. memory leaks 137 Pointer and object memory leaks can be tested for using fixtures by comparing the number of current pointers and objects during setup and teardown. 138 138 139 139 … … 141 141 ------------ 142 142 143 Compound, log, HTML 143 Results can be sent to a log file with the FILENAME keyword:: 144 144 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' 147 146 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 147 This will send the normal output to the results.log file. 148 149 HTML 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 158 153 159 154 Miscellaneous … … 166 161 ---- 167 162 168 Subclass a subclass of MGutTestCase.163 It 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. 169 164 165 The 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
