Changeset 105

Show
Ignore:
Timestamp:
10/21/10 14:32:15 (19 months ago)
Author:
mgalloy
Message:

Adding Makefile to generate PDF and HTML output from existing reStructuredText formatted docs.

Location:
trunk/docs
Files:
1 added
1 modified
1 moved

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
  • trunk/docs/using-mgunit.rst

    r51 r105  
     1Using mgunit 
     2============ 
     3 
     4:Author: Michael Galloy 
     5 
     6 
    17Introduction 
    28------------ 
     
    1016Individual 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".  
    1117 
    12 For example, let's create some tests for the FINDGEN function. First, subclass MGutTestCase like below:: 
     18For example, let's create some tests for the `FINDGEN` function. First, subclass `MGutTestCase` like below:: 
    1319 
    1420  pro findgen_ut__define 
     
    2935  end 
    3036 
    31 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:: 
     37Return 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:: 
    3238 
    3339  IDL> mgunit, 'findgen_ut' 
     
    8086--------------------------- 
    8187 
    82 Another test case, indgen_ut, is provided as an example. It is analogous to findgen_ut for the INDGEN routine. 
     88Another test case, `indgen_ut`, is provided as an example. It is analogous to `findgen_ut` for the `INDGEN` routine. 
    8389 
    8490Multiple test cases can be executed by specifying them as an array:: 
     
    102108  Results: 4 / 10 tests passed 
    103109 
    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_ut test cases:: 
     110Alternatively, 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:: 
    105111 
    106112  function indgen_uts::init, _extra=e 
     
    121127  end 
    122128 
    123 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". 
     129The 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". 
    124130 
    125131mgunit will also accept a mixed array of test suites and test cases, as in:: 
     
    133139-------- 
    134140 
    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. 
     141The 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. 
    136142 
    137143Pointer and object memory leaks can be tested for using fixtures by comparing the number of current pointers and objects during setup and teardown. 
     
    141147------------ 
    142148 
    143 Results can be sent to a log file with the FILENAME keyword:: 
     149Results can be sent to a log file with the `FILENAME` keyword:: 
    144150 
    145151  IDL> mgunit, 'indgen_uts', filename='test-results.log' 
     
    147153This will send the normal output to the results.log file. 
    148154 
    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:: 
     155HTML 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:: 
    150156 
    151157  IDL> mgunit, 'indgen_uts', filename='test-results.html', /html 
     
    155161------------- 
    156162 
    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". 
     163Templates 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". 
    158164 
    159165 
     
    161167---- 
    162168 
    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. 
     169It 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. 
    164170 
    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. 
     171The `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. 
    166172