mercredi 2 septembre 2020

A way to check coverage of API tests for Django applications with Pytest

I have an application based on Django framework. Under the repo of the Django app, there is a repo which contains API tests based on Pytest framework. I am using requests library to send a request to the server, and asserting on the response data.

An example of API test:

import requests
def test_some_api(self):
    s = requests.Session()
    response = s.get('/api/some_api')
    assert response.status_code == 200

Is there any way to know how many lines of code ran out of total amount of code lines of a given module due to the request above? I would like to know how many lines of codes has ran, and how many didn't due to the request above.

I managed to get a nice report with pytest-cov, but it works only for Unittests (calling functions directly from server repo).

Aucun commentaire:

Enregistrer un commentaire