← Back to team overview

launchpad-dev team mailing list archive

How to run a few unit tests a bit faster

 

I think most people use the -t option to bin/test to find tests to run.  This finds all possible tests, and then filters.  If you are only running some relatively svelte little tests without layer set up, this can be very noticeable.

You might like -m and -p.  -m runs the tests in a module.  -p runs the tests in a package.  For me on Launchpad, -t is about 3 times slower than -m or -p.

Examples, for the fun of it.

gary@gpellucid:~/launchpad/lp-branches/lsprof-on-demand$ time ./bin/test -t lp.services.profile.tests
Running zope.testing.testrunner.layer.UnitTests tests:
  Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds.
  Ran 20 tests with 0 failures and 0 errors in 0.564 seconds.
Tearing down left over layers:
  Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds.

real	0m10.906s
user	0m8.210s
sys	0m2.630s



gary@gpellucid:~/launchpad/lp-branches/lsprof-on-demand$ time ./bin/test -m lp.services.profile.tests
Running zope.testing.testrunner.layer.UnitTests tests:
  Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds.
  Ran 20 tests with 0 failures and 0 errors in 0.255 seconds.
Tearing down left over layers:
  Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds.

real	0m3.605s
user	0m2.870s
sys	0m0.730s



gary@gpellucid:~/launchpad/lp-branches/lsprof-on-demand$ time ./bin/test -p lp.services.profile
Running zope.testing.testrunner.layer.UnitTests tests:
  Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds.
  Running:
                  
  Ran 20 tests with 0 failures and 0 errors in 0.279 seconds.
Tearing down left over layers:
  Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds.

real	0m3.518s
user	0m2.610s
sys	0m0.900s

It's something. :-)

Gary


Follow ups