Skip to content

Instantly share code, notes, and snippets.

@NapalmHorn
Created July 30, 2014 03:53
Show Gist options
  • Save NapalmHorn/72eb9709fd2bec109429 to your computer and use it in GitHub Desktop.
Save NapalmHorn/72eb9709fd2bec109429 to your computer and use it in GitHub Desktop.
A cut and paste (aka boilerplate) unit test
import unittest
# import fuctions for testing
#import testFunction from testFile # replace with the name of your file and fuctions
#to test simply run 'python boilerplatetester.py'
class boilerplateTestCase(unittest.TestCase):
def test_boilplate_good(self):
"""Does the test case return true when expected"""
expectedResult = True #expected result for good data
testCase = 'testcase' # good input that should yield expectedResult
self.assertTrue(testFunction(testCase) == expectedResult)
def test_boilplate_bad(self):
"""Does the test case return not true when fed bad data"""
expectedResult = True #expected result for good data
testCase = 'testcasefail' #bad data that should not produce a pass
self.assertTrue(testFunction(testCase) != expectedResult) # make sure bad data does not return true
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment