Showing posts with the label unit tests

Extract more information from your Python unittests

Hi guys, I know you love to write your unittest with python unittest module since its so easy and fun .
But sometimes we need to have a little more information than usual. This article is for those who want to use the powers of unittest module to get better control. Have more decision variables to play with.

I am going to use the below test script for reference.

importunittestclassTestExample(unittest.TestCase): defsetUp(self): = 'Python'deftest_title(self): self.assertTrue(, 'Name not a title') deftest_string(self): self.assertTrue(isinstance(, str), ' variable is not a string') deftest_capital(self): self.assertEqual(,, 'Name not in capital')

Case 1:  Find number of test cases in your test script.

if __name__ == '__main__': # Creating a TestSuite object test_suite = unittest.TestLoader().loadTestsFromTestCase(TestExam…