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 –
- Update profile
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 -
# There is to define configuration, testing data or environment preparation.
# Define the testing cases execution here.
# 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.