following this line, <> brackets represent placeholders for changing names. even within example code
To check that no functionality has been accidentally sacrificed due to recent changes we establish test cases in the following manner:
First, a file has to be created conforming to: test_<name_of_test_topic>.py
Second, a class will be created representing the topic of the containing tests method in further detail:
class <DetailedTestTopic>Test(<AppropriateTestCaseClass>TestCase):
""" further explanation about this test class """
# [...]
Then the appropriate amount of test methods has to be created to achieve coverage. Creation follows a certain pattern:
# [...] code from previous step
def test_<descriptive_test_method_name>(self):
""" description of what this test tries to achieve """
logger.info("started <DetailedTestTopic>Test.test_<descriptive_test_method_name>")
# [...]
The prefix test_ signals this method to be a test and gets found and run when tests are supposed to be executed.
Also the test should contain at least one assertion, e.g.:
# [...]
self.assertEqual(calculated_variable, <expected_value>)
This results in the final combined pattern:
class <DetailedTestTopic>Test(<AppropriateTestCaseClass>TestCase):
""" further explanation about this test class """
def test_<descriptive_test_method_name>(self):
""" description of what this test tries to achieve """
logger.info("started <DetailedTestTopic>Test.test_<descriptive_test_method_name>")
# [...] insert test code resulting in calculated_variable
self.assertEqual(calculated_variable, <expected_value>)