question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests take longer to run when coverage context is recorded, expected?

See original GitHub issue

Perhaps you are already aware of this and it is expected, but at least for the purpose of documenting it:

Running tests while recording coverage context for who-tests-what (by using the .coveragerc mentioned below), takes considerably longer than usual. As a small example, running 300 unit tests used to take 15 seconds and with this it takes around 50 seconds. On bigger batches of tests it became quite impactful. Perhaps this is all expected.

The .coveragerc file is:

[run]
dynamic_context = test_function

As described in https://nedbatchelder.com/blog/201810/who_tests_what_is_here.html

The command was:

python coverage run -p --branch /path/py.test tests/unit/module/

Measured on:

Python==3.6.5
coverage==5.0a4

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nedbatcommented, Jul 7, 2019

I’ve made some more speed improvements on master. Can you try them?

1reaction
nedbatcommented, Oct 10, 2019

pytest-cov is a pytest plugin for coordinating coverage measurement during test runs. It’s faster for two reasons:

  • It starts coverage after pytest has collected tests, etc, so those early phases of pytest are not subject to the usual coverage slow-down
  • It uses internal pytest events to switch the dynamic context. Without that, coverage has to constantly check whether a new test has started.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Test coverage visualization - GitLab Docs
Coverage files are parsed in a background job so there can be a delay between pipeline completion and the visualization loading on the...
Read more >
Review test results - Azure Pipelines | Microsoft Learn
Tests, such as integration and functional tests, can run for a long time. Therefore, it is important to see the current or near...
Read more >
TestCoverage - Martin Fowler
Test coverage is a useful tool for finding untested parts of a codebase. Test coverage is of little use as a numeric statement...
Read more >
Improve Java Code Coverage and Quality with Unit Tests and ...
Rather than repeating yourself over and over, use a data-driven test to specify the expected inputs and the expected outputs. JUnit has built-in ......
Read more >
Django Tutorial Part 10: Testing a Django web application
They may cover simple groupings of components through to the whole ... The class also owns a test Client that you can use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found