Edgewall Software

Changes between Version 7 and Version 8 of TracDev/WritingUnitTests


Ignore:
Timestamp:
Jul 27, 2015, 8:53:35 PM (4 years ago)
Author:
figaro
Comment:

Cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/WritingUnitTests

    v7 v8  
    1 [[PageOutline()]]
     1[[PageOutline(2-5,Contents,pullout)]]
    22
    33= Writing unit tests
    44
    5 This wiki page shows how to write your own unit tests for Trac or Trac plugin.
     5This wiki page shows how to write your own unit tests for Trac or a Trac plugin.
    66
    77== Start writing `TestCase`s
    88
    9 Any unit test should derive from class `unittest.TestCase` in order to be called from `unittest.makeSuite`. Thus you can make a set of test cases, which are called test suite.
     9Any '''unit test''' should derive from class `unittest.TestCase` to be called from `unittest.makeSuite`. Thus you can make a set of '''test cases''', which are called '''test suite'''.
    1010
    11 Usually you need to setup your `Environment` in order to have any access to your Trac environment. This can be done using `EnvironmentStub`.
     11Usually you need to setup your `Environment` to have any access to your Trac environment. This can be done using `EnvironmentStub`.
    1212
    13 This test suite can be executed as a normal python code.
     13This test suite can be executed as a normal Python code.
    1414
    15 Here's a simple Test case (from trac plugin [th:wiki/LogWatcherPlugin LogWatcherPlugin]) to explain the above:
     15Here is a simple test case from Trac plugin [th:wiki/LogWatcherPlugin LogWatcherPlugin] to explain the above:
    1616
    1717{{{#!py
     
    6363== Using several test methods
    6464
    65 You can use several test methods within a `TestCase` class; they need to start with `test`. When you use method `setUp` it will be executed for each test method. If you only want to "set up" your test environment once of your test case, you need to use class method `setUpClass`.
     65You can use several test methods within a `TestCase` class; they need to start with `test`. When you use method `setUp` it will be executed for each test method. If you only want to "set up" your test environment once for your test case, you need to use class method `setUpClass`.
    6666
    6767Note that `setUpClass` and `tearDownClass` are available since Python 2.7.