Package trac :: Package tests :: Package functional

Package functional

source code

functional_tests

While unittests work well for testing facets of an implementation, they fail to provide assurances that the user-visible functions work in practice. Here, we complement the unittests with functional tests that drive the system as a user would to verify user visible functionality. These functional tests are run as part of the unittests.

So, we use Twill to verify Trac's functionality as served by tracd (and in the future, other frontends).

Unlike most unittests, we setup a single fixture against which we run all the testcases. This is for two reasons: Primarily, that provides us with a more complex set of data to test against and thus more room for triggering bugs. Secondarily, the cost of setting up a new Trac environment and Subversion repository is significant, so recreating the fixture for each test would be very costly.

There are two primary objects involved in the testing, the FunctionalTestEnvironment and the FunctionalTester.

FunctionalTestEnvironment represents the Trac environment, the Subversion repository, and the server. The server will be run on a random local port in the range 8000-8999. A subdirectory named 'tracenv' will be created containing the Trac environment, Subversion repository, and the user authentication information. An 'admin' user is created and given TRAC_ADMIN privs early in the testing. There are other users added as well. All accounts are setup with a password equalling the username. The test environment is left behind after the testing has completed to assist in debugging.

FunctionalTester provides code reuse for the testcases to allow a higher-level description of the more complicated bugs. For example, creating a new ticket is the first step in regression testing many things, so FunctionalTester provides a create_ticket() method. That method is written as if it were itself a testcase for creating a ticket, so there is a testcase that simply calls that method, and other testcases that use it as a higher-level step don't have to worry about basic issues such as if the ticket was successfully created.

Requirements:
Submodules

Classes
  FunctionalTestSuite
TestSuite that provides a test fixture containing a FunctionalTestEnvironment and a FunctionalTester.
  FunctionalTwillTestCaseSetup
  FunctionalTestCaseSetup
Convenience class to expand the fixture into the _testenv and _tester attributes.
Functions
 
regex_owned_by(username) source code
 
functionalSuite() source code
 
test_suite() source code
Variables
  has_svn = True
  internal_error = 'Trac detected an internal error:'
  trac_source_tree = '/usr/local/virtualenv/src/trac-0.13doc/svn...
  __package__ = 'trac.tests.functional'

Imports: os, subprocess, unittest, parse_version, core, trac, TestSetup, TestCaseSetup, b, tc, twill, FunctionalTestEnvironment, SvnFunctionalTestEnvironment, FunctionalTester, better_twill, svntestenv, testenv, tester


Variables Details

trac_source_tree

Value:
'/usr/local/virtualenv/src/trac-0.13doc/svn-trunk'