Diff for "Testing"

Not logged in - Log In / Register

Differences between revisions 1 and 15 (spanning 14 versions)
Revision 1 as of 2009-04-10 18:34:39
Size: 532
Editor: kfogel
Comment: Placeholder page.
Revision 15 as of 2010-04-12 15:50:04
Size: 3260
Editor: adiroiban
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
||<tablestyle="width: 100%;" colspan=3 style="background: #2a2929; font-weight: bold; color: #f6bc05;">This page is an introduction to writing and running test. All pages dedicated to testing can be found in CategoryTesting. ||

||<tablestyle="float:right; font-size: 0.9em; width:30%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>||

= Writing tests =

For each part of an application there are 2 level of testing:
 * unit testing
  * comprehensive testing, including cornerstone cases
  * written in python files (no doctest)
 * smoke/functional/integration testing
  * testing normal use cases, simple or comples
  * written using doctest format

1. Model
 1. Unit testing
  * Files locate in lib/lp/<application>/scripts/tests
 1. Smoke testing
  * Files locate in lib/lp/<application>/doc
1. View
 1. Unit testing
  * Files locate in lib/lp/<application>/browser/tests
 1. Smoke testing
  * Files locate in lib/lp/<application>/stories
  * More details: PageTests
1. Javascript
 1. Unit testing
  * More details: TestingJavaScript JavascriptUnitTesting
 1. Smoke testing
  * Files locate in lip/lp/<application>/windmill (if written in Python) and lib/canonical/launchpad/windmill/jstests
(if written in JS)
  * More details: [[Windmill]]
1. Scripts
  * Files locate in lib/lp/<application>/scripts/tests
1. API
  * Files located in lib/lp/<application>/stories/webservices
  * More details: TestingWebServices
Line 5: Line 43:
Obviously, you've already tested your changes manually and confirmed that they do what you expect. == General usage ==
The normal pattern for testing your changes is to run the tests you ''think'' will be affected locally, and then (possibly just before submission) run '''all''' the tests [[EC2Test|in the cloud]] before landing your changes on [[Trunk|trunk]].
Line 7: Line 46:
But how do you know they don't do anything you ''don't'' expect? To run the tests, you run the {{{./bin/test}}} script, which is produced by {{{make build}}}.
Line 9: Line 48:
Hence the test suite :-). You can see all the options you have by running {{{./bin/test --help}}}.
Line 11: Line 50:
The test suite runs remotely, in Amazon's EC2 computing cloud. ''TODO: we need to set up some way to give EC2 time to non-Canonical developers. Our internal instructions for testing on EC2 are not well-suited to external contributors.'' Usually you will run {{{./bin/test -vvct PATTERN}}} where {{{PATTERN}}} is a regular expression that is used to filter the tests that will be run.

You can use '!PATTERN' to match all expression not matching that patter.
Ex, to run all test, except the one at Windmill layer you can use:
{{{
./bin/test -vvc --layer '!Windmill'
}}}

== Speed up the tests ==

Since Librarian and MemCache does not change often and they take a long time to be started and shutdown, ./bin/test can leave them started by using this command:
{{{
LP_PERSISTENT_TEST_SERVICES=1 ./bin/test PATTERN
}}}

You can kill them using {{{ ./bin/kill-test-services }}}

When running tests written in python files, and you only want to test a file, you can speed up the test by specifying the full path to the python file:
{{{
LP_PERSISTENT_TEST_SERVICES=1 ./bin/test PATH/TO/PYTHON/TEST/FILE.py
}}}

See [[https://lists.launchpad.net/launchpad-dev/msg02780.html|this mail]] for more.

== Headless Windmill tests ==

 * In case you are running windmill test on a machine without X server, you can use xvfb-run to run WindmillTests:
{{{
xvfb-run -s '-screen 0 1024x768x24' bin/test YOUR_TEST_ARGUMENTS
}}}

----
CategoryTesting

This page is an introduction to writing and running test. All pages dedicated to testing can be found in CategoryTesting.

Writing tests

For each part of an application there are 2 level of testing:

  • unit testing
    • comprehensive testing, including cornerstone cases
    • written in python files (no doctest)
  • smoke/functional/integration testing
    • testing normal use cases, simple or comples
    • written using doctest format

1. Model

  1. Unit testing
    • Files locate in lib/lp/<application>/scripts/tests

  2. Smoke testing
    • Files locate in lib/lp/<application>/doc

1. View

  1. Unit testing
    • Files locate in lib/lp/<application>/browser/tests

  2. Smoke testing
    • Files locate in lib/lp/<application>/stories

    • More details: PageTests

1. Javascript

  1. Unit testing
  2. Smoke testing
    • Files locate in lip/lp/<application>/windmill (if written in Python) and lib/canonical/launchpad/windmill/jstests

(if written in JS)

1. Scripts

  • Files locate in lib/lp/<application>/scripts/tests

1. API

  • Files located in lib/lp/<application>/stories/webservices

  • More details: TestingWebServices

Testing Your Launchpad Changes

This page is very much still in progress.

General usage

The normal pattern for testing your changes is to run the tests you think will be affected locally, and then (possibly just before submission) run all the tests in the cloud before landing your changes on trunk.

To run the tests, you run the ./bin/test script, which is produced by make build.

You can see all the options you have by running ./bin/test --help.

Usually you will run ./bin/test -vvct PATTERN where PATTERN is a regular expression that is used to filter the tests that will be run.

You can use '!PATTERN' to match all expression not matching that patter. Ex, to run all test, except the one at Windmill layer you can use:

./bin/test -vvc --layer '!Windmill'

Speed up the tests

Since Librarian and MemCache does not change often and they take a long time to be started and shutdown, ./bin/test can leave them started by using this command:

LP_PERSISTENT_TEST_SERVICES=1 ./bin/test PATTERN 

You can kill them using  ./bin/kill-test-services 

When running tests written in python files, and you only want to test a file, you can speed up the test by specifying the full path to the python file:

LP_PERSISTENT_TEST_SERVICES=1 ./bin/test PATH/TO/PYTHON/TEST/FILE.py

See this mail for more.

Headless Windmill tests

  • In case you are running windmill test on a machine without X server, you can use xvfb-run to run WindmillTests:

xvfb-run -s '-screen 0 1024x768x24' bin/test YOUR_TEST_ARGUMENTS


CategoryTesting

Testing (last edited 2020-07-16 16:51:31 by doismellburning)