Jeroen T. Vermeulen has proposed merging 
lp:~jtv/launchpad/decruft-test-template into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code


= Decruft standard test template =

This is an update I'd like for the sample unit-test file we provide in the 
project's top-level directory.

The boilerplate at the bottom of the test is no longer needed, as far as I 
know. If this is correct, I'd also like to remove it from as many existing 
tests as I reasonably can.

I also documented some guidelines and typical steps, such as the layer. I don't 
know how it is for others but I'm generally too lazy to remember what layers 
there are and where to import them from, so I included that information.

Is this too much? I don't want engineers to have to spend more time deleting 
text from the sample than they would otherwise spend putting up scaffolding.

The new file is lint-free. This is why the "XXX: Sample test class" comment is 
inside the test class, not above it: otherwise "make lint" would expect a 
double blank line between the comment and the class definition.

The new sample test also actually passes. Perhaps it would be worthwhile to 
make it part of the test suite so that we can be sure it doesn't fall out of 
date.

Jeroen
-- 
https://code.launchpad.net/~jtv/launchpad/decruft-test-template/+merge/30083
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~jtv/launchpad/decruft-test-template into lp:launchpad/devel.
=== modified file 'standard_test_template.py'
--- standard_test_template.py	2010-01-12 03:07:09 +0000
+++ standard_test_template.py	2010-07-16 10:37:43 +0000
@@ -5,10 +5,20 @@
 
 __metaclass__ = type
 
-import unittest
-
+from canonical.testing import DatabaseFunctionalLayer
 from lp.testing import TestCase
 
 
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)
+class TestSomething(TestCase):
+    # XXX: Sample test class.  Replace with your own test class(es).
+
+    # XXX: Optional layer--see lib/canonical/testing/layers.py
+    # Get the simplest layer that your test will work on, or if you
+    # don't even use the database, don't set it at all.
+    layer = DatabaseFunctionalLayer
+
+    # XXX: Sample test.  Replace with your own test methods.
+    def test_baseline(self):
+
+        # XXX: Assertions take expected value first, actual value second.
+        self.assertEqual(4, 2 + 2)

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to