Changeset 105
- Timestamp:
- 10/21/10 14:32:15 (19 months ago)
- Location:
- trunk/docs
- Files:
-
- 1 added
- 1 modified
- 1 moved
-
. (modified) (1 prop)
-
Makefile (added)
-
using-mgunit.rst (moved) (moved from trunk/docs/using-mgunit.txt) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs
-
Property
svn:ignore set
to
using-mgunit.aux
using-mgunit.tex
using-mgunit.html
using-mgunit.out
using-mgunit.pdf
using-mgunit.log
using-mgunit.ps
using-mgunit.dvi
-
Property
svn:ignore set
to
-
trunk/docs/using-mgunit.rst
r51 r105 1 Using mgunit 2 ============ 3 4 :Author: Michael Galloy 5 6 1 7 Introduction 2 8 ------------ … … 10 16 Individual tests are methods of a class that subclasses MGutTestCase. Each method returns 1 for success or 0 (or throws an error) for failure. Each test method's name must start with "test". 11 17 12 For example, let's create some tests for the FINDGEN function. First, subclass MGutTestCaselike below::18 For example, let's create some tests for the `FINDGEN` function. First, subclass `MGutTestCase` like below:: 13 19 14 20 pro findgen_ut__define … … 29 35 end 30 36 31 Return 1 for success. For failure, either return 0 or throw an error. Here the helper routine ASSERTwill throw an error using the given message if its condition is not met. This will be reported as a failure along with the message. To run this test, use the following::37 Return 1 for success. For failure, either return 0 or throw an error. Here the helper routine `ASSERT` will throw an error using the given message if its condition is not met. This will be reported as a failure along with the message. To run this test, use the following:: 32 38 33 39 IDL> mgunit, 'findgen_ut' … … 80 86 --------------------------- 81 87 82 Another test case, indgen_ut, is provided as an example. It is analogous to findgen_ut for the INDGENroutine.88 Another test case, `indgen_ut`, is provided as an example. It is analogous to `findgen_ut` for the `INDGEN` routine. 83 89 84 90 Multiple test cases can be executed by specifying them as an array:: … … 102 108 Results: 4 / 10 tests passed 103 109 104 Alternatively, test cases may be grouped into test suites. Test suites are just collections of test cases. To make a suite, subclass MGutTestSuite and use the add method in the the subclass' init method to add test classes. For example, to make a suite containing the indgen_ut and findgen_uttest cases::110 Alternatively, test cases may be grouped into test suites. Test suites are just collections of test cases. To make a suite, subclass `MGutTestSuite` and use the add method in the the subclass' init method to add test classes. For example, to make a suite containing the `indgen_ut` and `findgen_ut` test cases:: 105 111 106 112 function indgen_uts::init, _extra=e … … 121 127 end 122 128 123 The commented out line will specifically add indgen_ut and findgen_ut, wherever their source code files may be located. Instead, the ALLkeyword is used to add all test cases in the same directory as the test suite source code file. Test cases to be found in this manner must use the convention to name the class with an appended "_ut", as in "findgen_ut".129 The commented out line will specifically add `indgen_ut` and `findgen_ut`, wherever their source code files may be located. Instead, the `ALL` keyword is used to add all test cases in the same directory as the test suite source code file. Test cases to be found in this manner must use the convention to name the class with an appended "_ut", as in "findgen_ut". 124 130 125 131 mgunit will also accept a mixed array of test suites and test cases, as in:: … … 133 139 -------- 134 140 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 MGutTestCasecan 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.141 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 142 137 143 Pointer and object memory leaks can be tested for using fixtures by comparing the number of current pointers and objects during setup and teardown. … … 141 147 ------------ 142 148 143 Results can be sent to a log file with the FILENAMEkeyword::149 Results can be sent to a log file with the `FILENAME` keyword:: 144 150 145 151 IDL> mgunit, 'indgen_uts', filename='test-results.log' … … 147 153 This will send the normal output to the results.log file. 148 154 149 HTML output can also be created with the boolean HTML keyword to the MGUNIT routine. Generally, the FILENAMEkeyword is used in conjunction with this option::155 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 156 151 157 IDL> mgunit, 'indgen_uts', filename='test-results.html', /html … … 155 161 ------------- 156 162 157 Templates for the IDL Workbench are provided to make test/suite creation even faster. To use them, first navigate to the Workbench preferences. There should be a Templates section under the IDL heading. Click the "Import" button on the right and navigate to the "test-templates.xml"file in the mgunit source. Two new templates, "Test case" and "Test suite", should now be available. Typing "testcase" into a new file and then selecting Edit > Content Assist from the menus will create a test case which can be filled out like a form. Suites can be created the same way by typing "testsuite".163 Templates for the IDL Workbench are provided to make test/suite creation even faster. To use them, first navigate to the Workbench preferences. There should be a Templates section under the IDL heading. Click the "Import" button on the right and navigate to the `test-templates.xml` file in the mgunit source. Two new templates, "Test case" and "Test suite", should now be available. Typing "testcase" into a new file and then selecting Edit > Content Assist from the menus will create a test case which can be filled out like a form. Suites can be created the same way by typing "testsuite". 158 164 159 165 … … 161 167 ---- 162 168 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 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. 164 170 165 The NTESTS, NPASS, and NFAIL keywords to the MGUNITroutine output the appropriate values. These can be handy for automated scripts i.e. sending email if any test fails, etc.171 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 172
