summaryrefslogtreecommitdiffstats
path: root/nova/testing
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-07 17:08:00 +0000
committerGerrit Code Review <review@openstack.org>2012-03-07 17:08:00 +0000
commit8623fd981b9a1e29a68a0853e07aa8d016b8d99b (patch)
tree8766479ae25aa7fb2a3442ed70af30cb37f408e9 /nova/testing
parentf9b049734f2b973790924779fd1f3c45c1545833 (diff)
parentfb7d1fb8253e55437858358793c9fb02fbff0ba0 (diff)
downloadnova-8623fd981b9a1e29a68a0853e07aa8d016b8d99b.tar.gz
nova-8623fd981b9a1e29a68a0853e07aa8d016b8d99b.tar.xz
nova-8623fd981b9a1e29a68a0853e07aa8d016b8d99b.zip
Merge "Clear created attributes when tearing down tests"
Diffstat (limited to 'nova/testing')
-rw-r--r--nova/testing/README.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/nova/testing/README.rst b/nova/testing/README.rst
index 036f1c77d..67fa33d1d 100644
--- a/nova/testing/README.rst
+++ b/nova/testing/README.rst
@@ -33,6 +33,17 @@ Using Fakes
TBD
+test.TestCase
+-------------
+The TestCase class from nova.test (generally imported as test) will
+automatically manage self.stubs using the stubout module and self.mox
+using the mox module during the setUp step. They will automatically
+verify and clean up during the tearDown step.
+
+If using test.TestCase, calling the super class setUp is required and
+calling the super class tearDown is required to be last if tearDown
+is overriden.
+
Writing Functional Tests
------------------------
@@ -42,3 +53,14 @@ Writing Integration Tests
-------------------------
TBD
+
+Tests and assertRaises
+----------------------
+When asserting that a test should raise an exception, test against the
+most specific exception possible. An overly broad exception type (like
+Exception) can mask errors in the unit test itself.
+
+Example::
+
+ self.assertRaises(exception.InstanceNotFound, db.instance_get_by_uuid,
+ elevated, instance_uuid)