Skip to content

mawada-sweis/unitTest

Repository files navigation

Testing in Python: Unit Tests

This repo contains an exmaple of a unit tests in python. In this repo, I show how to run the unit tests, it achieving 100% test coverage by the full path of each methods Click here to see the paths and Control Flow Graphs

  • install the dependanceies:
pip3 install -r requirements.txt 

Steps

Run test using pytest

pytest test_calculatorApp.py 

Code coverage

  • To display the code coverage page, open the htmlcov folder then open the index.html file on your browser.
  • To create a more concise html version of the report, Run:
   coverage html 

Run the test and generate code coverage

  • Run the following command to run the tests and print the code coverage:

    pytest --cov=calculatorApp 
  • To display the report page, open the htmlcov folder then open the calculatorApp_py.html file on your browser.
  • Run the following command to run the tests and generate html report for the code coverage:

    pytest --cov=calculatorApp --cov-report=html 

About

Practice on unit test by using Python

Topics

Resources

Stars

Watchers

Forks

Languages