I have an existing python script that I'd like to test with python's unittest libary, specifically using unittest.FunctionTestCase()
Can anyone provide a simple 'actual' example of how someone might do this?
cheers for help
def test_something(self):
testCase1 = unittest.FunctionTestCase(existingFunctionToLoadWebPage)
testCase2 = unittest.FunctionTestCase(existingFunctionToSubmitWebForm)
testSuite = unittest.TestSuite((testCase1, testCase2))
self.assertEqual(suite.countTestCases(), 2)
# Validate the two existing functions above worked, even though then don't return anything:
self.assertEqual(suite.testCase1)
self.assertEqual(suite.testCase2)
FunctionTestCase
? Is it just "I want to test a function, and FunctionTestCase
sounds like a class designed to do that"? If so, you've misunderstood what FunctionTestCase
is, and you should just write a normal test with unittest.TestCase
.