Commits

Mikhail Korobov committed ee00433

Some extra docs on testing; tests are finally divided into fast and slow.

Comments (0)

Files changed (3)

 ---
 
 - OS is now auto-detected;
-- Ubuntu 10.10 maverick initial support;
+- Ubuntu 10.10 maverick initial support (need better testing);
 - `fabtest <https://bitbucket.org/kmike/fabtest>`_ package is extracted
   from the test suite;
-- more tests.
+- more and better tests;
+- :func:`fab_deploy.system.ssh_add_key` can now add ssh key even
+  if is is the first key for user
 
 0.4.2 (2011-02-16)
 ------------------
 Preparations
 ------------
 
-django-fab-deploy requires `fabtest`_ package for running tests and
-(optionally) ``coverage.py`` for test coverage reports::
+django-fab-deploy requires latest `fabtest`_ package for running tests and
+(optionally) `coverage.py`_ for test coverage reports::
 
     pip install -U fabtest
     pip install coverage
 
 .. _VirtualBox: http://www.virtualbox.org/
 .. _fabtest: https://bitbucket.org/kmike/fabtest
+.. _coverage.py: http://pypi.python.org/pypi/coverage
 
 Running tests
 -------------
     cd fab_deploy_tests
     ./runtests.py <VM name or uid> <what to run>
 
-<what to run> can be `fast`, `all` or any value acceptable by
+<what to run> can be ``fast``, ``slow`` or any value acceptable by
 ``unittest.main()`` (e.g. a list of test cases).
 
+Some tests require additional prepared snapshots in order to greatly speedup
+test execution. But there is a chicken or the egg dilemma: these
+snapshots can be only taken if software works fine for the VM (at least
+tests are passed). So tests are divided into 'slow' and 'fast' suites.
+
+1. make sure slow tests are passing::
+
+       ./runtests.py "VM_NAME" slow
+
+2. prepare snapshots::
+
+       ./preparevm "VM_NAME"
+
+3. faster tests can be run now::
+
+       ./runtests.py "VM_NAME" fast
+
+
+Coverage reports
+----------------
+
 In order to get coverage reports run::
 
     cd fab_deploy_tests

fab_deploy_tests/runtests.py

 import sys
 import os.path
 import unittest
+from unittest import TestSuite, TestLoader
 from fab_deploy_tests.tests import *
 
 # always use fab_deploy from the checkout, not the installed version
 path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
 sys.path.insert(0, path)
 
-def get_suite(cases):
-    suites = map(unittest.TestLoader().loadTestsFromTestCase, cases)
-    return unittest.TestSuite(suites)
+def load(cases):
+    return map(TestLoader().loadTestsFromTestCase, cases)
 
 def help():
     print 'usage: runtests.py "VM_NAME" <what_to_run>\n'
         sys.exit(1)
 
     FabDeployTest.vm_name = sys.argv[1]
+    common_tests = load([BasicTest, SshTest, MysqlTest])
     suites = {
-        'fast': get_suite([BasicTest, SshTest, FastPrepareServerTest, MysqlTest]),
-        'slow': get_suite([PrepareServerTest])
+        'fast': TestSuite(common_tests + load([FastPrepareServerTest])),
+        'slow': TestSuite(common_tests + load([PrepareServerTest])),
     }
 
-    suites['all'] = unittest.TestSuite(suites.values())
-
     suite_name = sys.argv[2]
     if suite_name in suites:
         unittest.TextTestRunner().run(suites[suite_name])