How can I use pytest-cov to both generate a coverage report and also print to terminal?

sunyata

Background

I'm new to using pytest and pytest-cov having switched over from unittest + coverage.py

I first set up my automated tests to run in this way:

python3 -m pytest --cov=myapplication

which gave me output like this to the terminal:

----------- coverage: platform linux, python 3.8.5-final-0 -----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
myapplication/__init__.py       0      0   100%
myapplication/file.py          30     30     0%
myapplication/another_file.py  20      6    70%
[...]
-----------------------------------------------
TOTAL                        1195    464    61%

Then i wanted to generate an xml report so i changed the command:

python3 -m pytest --cov-report xml:coverage.xml --cov=myapplication

Problem

The problem i'm having is that after adding --cov-report xml:coverage.xml i no longer get any output to the terminal

Looking at the documentation for pytest-cov i find this:

These three report options output to files without showing anything on the terminal: [goes on to show xml, html and annotation reporting options]

Question

How can i both generate a report and also print to terminal in the same test run? (Is this even possible?)

(I could run the test suite two times, but if i can i'd like to do everything at once)


I am using these versions:

  • Python 3.8.5
  • pytest 6.2.2 (the latest version as of writing this)
  • pytest-cov 2.11.1 (-"-)
Jack Taylor

You can do this by specifying another --cov-report argument with one of the terminal output formats. You can have --cov-report term or --cov-report term-missing. For example:

python3 -m pytest --cov-report term --cov-report xml:coverage.xml --cov=myapplication

See the pytest-cov docs you linked to for how term and term-missing work.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to generate test coverage report in Meteor / Velocity?

From Dev

How to generate a detail report of functional coverage in Questasim?

From Dev

How can I print a Blank report in SSRS

From Java

How can I print literal curly-brace characters in python string and also use .format on it?

From Dev

How can I print literal curly-brace characters in a string and also use .format on it?

From Dev

How can I print literal curly-brace characters in a string and also use .format on it?

From Dev

Generate coverage report with stack

From Dev

Generate coverage report with stack

From Dev

How to setup a different html output directory for coverage report with pytest?

From Dev

Missing test coverage for class declaration with pytest-cov

From Java

How do I read an Istanbul Coverage Report?

From Dev

How can I generate both standard accessors and fluent accessors with lombok?

From Dev

How do I use bash to generate a du mail report?

From Dev

How can I generate a statistical date range report in PHP and MySQL?

From Dev

pytest how to use both gdetoption and parameterize

From Dev

pytest how to use both getoption and parameterize

From Java

How can I use swift in Terminal?

From Dev

How can I use the mouse in a virtual terminal?

From Dev

How can I use Kazam Screencaster In Terminal?

From Dev

Can I use istanbul to instrument for mocha html-cov

From Dev

How can I print output whilst detached from controlling terminal?

From Dev

How can I use a pytest fixture as a parametrize argument?

From Dev

How can I use pytest.raises with multiple exceptions?

From Dev

How can i print the report in excel format using aeroo report on Openerp7

From Dev

How can I use a push to deploy strategy to also pull data?

From Dev

How can I both load my Simulink model to my Arduino and add also my own code with it?

From Dev

How can i report from backgroundworker dowork event to listView and also to toolStripStatusLabel?

From Dev

PyDevD is preventing pytest to correctly generate coverage

From Dev

How to print number of characters based on terminal width that also resize?

Related Related

  1. 1

    How to generate test coverage report in Meteor / Velocity?

  2. 2

    How to generate a detail report of functional coverage in Questasim?

  3. 3

    How can I print a Blank report in SSRS

  4. 4

    How can I print literal curly-brace characters in python string and also use .format on it?

  5. 5

    How can I print literal curly-brace characters in a string and also use .format on it?

  6. 6

    How can I print literal curly-brace characters in a string and also use .format on it?

  7. 7

    Generate coverage report with stack

  8. 8

    Generate coverage report with stack

  9. 9

    How to setup a different html output directory for coverage report with pytest?

  10. 10

    Missing test coverage for class declaration with pytest-cov

  11. 11

    How do I read an Istanbul Coverage Report?

  12. 12

    How can I generate both standard accessors and fluent accessors with lombok?

  13. 13

    How do I use bash to generate a du mail report?

  14. 14

    How can I generate a statistical date range report in PHP and MySQL?

  15. 15

    pytest how to use both gdetoption and parameterize

  16. 16

    pytest how to use both getoption and parameterize

  17. 17

    How can I use swift in Terminal?

  18. 18

    How can I use the mouse in a virtual terminal?

  19. 19

    How can I use Kazam Screencaster In Terminal?

  20. 20

    Can I use istanbul to instrument for mocha html-cov

  21. 21

    How can I print output whilst detached from controlling terminal?

  22. 22

    How can I use a pytest fixture as a parametrize argument?

  23. 23

    How can I use pytest.raises with multiple exceptions?

  24. 24

    How can i print the report in excel format using aeroo report on Openerp7

  25. 25

    How can I use a push to deploy strategy to also pull data?

  26. 26

    How can I both load my Simulink model to my Arduino and add also my own code with it?

  27. 27

    How can i report from backgroundworker dowork event to listView and also to toolStripStatusLabel?

  28. 28

    PyDevD is preventing pytest to correctly generate coverage

  29. 29

    How to print number of characters based on terminal width that also resize?

HotTag

Archive