Edgewall Software

Changes between Version 21 and Version 22 of TracDev/UnitTests


Ignore:
Timestamp:
Nov 18, 2016, 5:55:12 PM (7 years ago)
Author:
Ryan J Ollos
Comment:

Add information on how to execute test classes and test cases. Use unittest in example of executing package and module test cases, for consistency.

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/UnitTests

    v21 v22  
    33= Trac Unit Tests
    44
    5 Many of the Trac Python modules are accompanied by unit tests. You should run the tests whenever making changes, to be confident you haven't broken anything. Note though that the coverage of application code by the unit tests is still rather poor, and even if it were better, not having broken the unit tests does not mean you haven't broken the application! Unit tests do not replace manual testing.
     5Many of the Trac Python modules are accompanied by unit tests. You should run the tests whenever making changes, to be confident you haven't broken anything. Note though that the coverage of application code by the unit tests is incomplete, so not having broken the unit tests does not mean you haven't broken the application! Unit tests do not replace manual testing.
    66
    77Ideally, also include new unit tests for a change or enhancement, even if you are just submitting a patch. Patches that break the unit tests are a lot less likely to get integrated than patches that add unit tests for the new or changed functionality.
     
    1111You can run the unit tests from the command line by executing:
    1212{{{#!sh
    13 python -m trac.test --skip-functional-tests
     13$ python -m trac.test --skip-functional-tests
    1414}}}
    1515
     
    2828Assuming the current working directory is where you checked out the Trac code from the SubversionRepository.
    2929
    30 This will run all the unit tests, but you can also run only those tests for a specific package or module. For example, to run the unit tests for the {{{trac.versioncontrol}}} package, execute:
     30This will run all the unit tests, but you can also run only the tests for a specific package, module, class or method. For example, to run the unit tests for the `trac.versioncontrol` package, execute:
    3131{{{#!sh
    32 python -m trac.versioncontrol.tests.__init__
     32$ python -m unittest trac.versioncontrol.tests.__init__
    3333}}}
    3434
     
    3838}}}
    3939
    40 To run the unit tests for the {{{trac.versioncontrol.cache}}} module, execute:
     40To run the unit tests for the `trac.versioncontrol.cache` module, execute:
    4141{{{#!sh
    42 python -m trac.versioncontrol.tests.cache
     42$ python -m unittest trac.versioncontrol.tests.cache
    4343}}}
    4444
     
    4646{{{#!sh
    4747$ PYTHONPATH=. trac/versioncontrol/tests/cache.py
     48}}}
     49
     50To run the unit tests for the test class `trac.versioncontrol.tests.cache.CacheTestCase`, execute:
     51{{{#!sh
     52$ python -m unittest trac.versioncontrol.tests.cache.TestCase
     53}}}
     54
     55To run the test case `trac.versioncontrol.tests.cache.CacheTestCase.test_initial_sync`, execute:
     56{{{#!sh
     57$ python -m unittest trac.versioncontrol.tests.cache.TestCase.test_initial_sync
    4858}}}
    4959