• 3-Step to generate Python Unit Test HTML Report?

    In this article, we will share how to generate your python unit testing results in HTML format.

    Here is the example of the testing reports. Generating testing report in HTML format will help others to read and share the testing results.





    Step 1: Download the HTMLTestRunner.py



    Step 2: Python Code Sample

    import unittest
    import HTMLTestRunner
    ... define your tests here...
    if __name__ == '__main__':
    Testing Results in HTML

    Step 3: Execution 

    Assuming the file name of python source code is “yourTestingPython.py” and the expected HTML testing results is “TestingResults.HTML”

    Python    yourTestingPython.py   >   TestingResults.HTML




    Tags: ,

  • Unittest in Python for Dummy

    In this article, we will introduce the following topic for dummy. We are going to answer the following questions.

    • What is unittest?
    • What are available unittest library for python?
    • How to use TestCase class in Python source code?
    • TestSuite for a group of tests
    • HTML test

    What is unitTest?

    The word “Unit” means break the whole testing suite into testing cases. If we apply it to Web automation, then you will have a testing suite which includes many unit testing scenario. For example –

    • Login
    • Update profile
    • Logout
    • ….

    For the selenium/python, we will need unitTest framework to help us to manage these unit testing scenario, execution, verify or assert testing results.

    In addition, we may also prepare the testing data or configuration before each unit testing scenario and reset the environment or configuration at the end of each unit testing cases. that’s why we need unitTesting framework here.


    What are unittesting Framework Available for Python?


    how to use UnitTesting in Python?

    Uses of UnitTesting, your python code structure will look like -
    import unittest
    Class my1stTest(unittest.TestCase):
    def setUp(self):
    # There is to define configuration, testing data or environment preparation. 
    def test_testCase1(self):
    # Define the testing cases execution here.
    def tearDown(self):
    # It's to reset the environment or close the browser.
    if __name__ == '__main__':


    HTML testing Reports

    Finally, if we would like the testing results in HTML format. We may use HTMLTestRunner.

    For how to use it, refer here.