If you are running a version of Python prior to 3.3 you must specify the number of processes to run simultaneously (e.g. Finally, if you want to run tests under a more strenuous set of settings, you can run test as./. This executes the test runner by discovering all classes in this file that inherit from unittest.TestCase. This is one of many ways to execute the unittest test runner. When you have a single test file named test.py, calling python test.py is a great way to get started. Another way is using the unittest command line.
Test Results
Jan 29, 2017 HtmlTest runner is a unittest test runner that save test results in Html files, for human readable presentation of results. This Package was inspired in unittest-xml-reporting and HtmlTestRunner by tungwaiyip.
Once you have a Selenium test run, you need to analyze the results as well. For that you need to have all your test reports organized clearly, and run properly so that you have the visibility and the run reports all at one place so that you can take a look at it better.
Once of the most common disadvantages of Selenium is that it doesn’t allows you the reporting capability. You need to have a third party framework to help obtain a well detailed report of the tests that you run.
For Java, we have TestNG which serves this purpose. For Python, we have
- HTMLTestRunner
- Allure
- Nose
which allows us to take out a well detailed report in HTML format.
Today we will see how we can use the HTMLTestRunner to generate a HTML report for our Selenium tests.
We will
- Create a simple suite of test cases
- Use HTMLTestRunner to generate an HTML report of the test cases in test suite.
Creating A Test Suite
A Test Suite is a collection of two or more test scripts, run together using a single runner. So, in a test suite, we would combine many test scripts and then call them together so that they are executed one by one.
Let us take two simple scripts .
This is a very simple script, where we are opening the wikipedia page and typing Sachin Tendulkar in search box of wiki webpage.
Let’s take another simple script
In this script, we’re opening the Youtube home page and typing Metallica in the search box.
Once we have both the scripts, let’s create a test suite for both these test cases
Python Unittest Xmlrunner
Now, we have our test suite. The suite takes the HTMLTestRunner extension and runs a tests and then creates a nice report out of it.
Let’s have a look at the report
It looks good. It’s not as fancy as the one provided by Allure, but it does the work. The HTMLTestRunner along with the test suite scripts are here in my repo.