'How to get code coverage from selenium tests of source code
We have different types of testing like unit testing and selenium automation testing using python in our application. Unit test's purpose is to check piece of code is working as expected and selenium test's purpose is to check web application is working as expected. We use coverage.py to get coverage from the tests. To run both type of tests we use commands like,
coverage run unit_test_command and coverage run selenium_test_command. After generating unit test coverage report we see report contains the data of test and source code which is tested. But after generating coverage report from selenium test we see report only contains the selenium test coverage which is of no use to us in terms of code coverage of application.
Via selenium test we do these steps in general:
- Hit the web application URL
- Check elements related to a feature(eg, for login page, username and password web elements are present and after sending valid values login submit click passes)
- Return test result
In selenium test we do understand we are not importing any source code but even if we are hitting any URL and clicking submit or doing any action, it should trigger some source code and so we expect those lines of code should get covered and should reflect in the report.
Is there some way we can get coverage of source code from selenium tests.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
