Permalink
Browse files

- Restructure the testing strategy from flags to a log.

  • Loading branch information...
1 parent b64839e commit 6d8bd7e368477eaff793241bb930ff5a21b14154 @lreij committed Mar 26, 2012
Showing with 14 additions and 10 deletions.
  1. +14 −10 xUnit/xUnit.py
View
@@ -10,39 +10,43 @@ def __init__(self, name):
def setUp(self):
pass
+ def tearDown(self):
+ pass
+
def run(self):
self.setUp()
method = getattr(self, self.name)
method()
+ self.tearDown()
class WasRun(TestCase):
def setUp(self):
self.wasRun = None
- self.wasSetUp = 1
+ self.log = "setUp "
def testMethod(self):
self.wasRun = 1
+ self.log += "testMethod "
+
+ def tearDown(self):
+ self.log += "tearDown "
class TestCaseTest(TestCase):
def setUp(self):
self.test = WasRun("testMethod")
- def testSetUp(self):
- self.test.run()
- assert(self.test.wasSetUp)
-
- def testRunning(self):
- self.test.run()
- assert(self.test.wasRun)
+ def testTemplateMethod(self):
+ test = WasRun("testMethod")
+ test.run()
+ assert("setUp testMethod tearDown " == test.log)
def main():
- TestCaseTest("testRunning").run()
- TestCaseTest("testSetUp").run()
+ TestCaseTest("testTemplateMethod").run()
if __name__ == '__main__':

0 comments on commit 6d8bd7e

Please sign in to comment.