Questions tagged [code-coverage]

"Code coverage" (synonym: test coverage) is a measure of the amount of application source code that has been exercised, usually by some testing regime, often by unit testing.

Code coverage is a measure of the amount of application source code that has been exercised, usually by some testing regime, often by unit testing. There are two key questions: given an exercise regime, how much of the source code is executed (under the assumption that the exercise also shows the program effects to be correct), and, given an exercise regime, how does one increase the coverage amount by modifying the exercise.

Determining the actual coverage is normally accomplished by instrumenting the source code to track when its elements are executed, and then simply running the exercise regime. The instrumented data is collected and often displayed in a report and/or a visual display.

Improving coverage given a specific exercise regime is difficult. One must determine for some block of uncovered code, how to cause that code to be executed, often requiring a complex initialization of the program environment to trigger the code block.

Code coverage is also known as , but see that tag's wiki for an alternate meaning.

5306 questions
3
votes
1 answer

interpret python coverage unit testing

I am currently unit testing and was confused on the the below: Name Stmts Miss Branch BrPart Cover Missing ------------------------------------------------------------------- src/__init__.py 0 …
skimchi1993
  • 189
  • 2
  • 9
3
votes
4 answers

Coverage python library not found after installing

I ran the command pip install coverage and it appears to have installed correctly. Frodo:Triangle567 tarikkdiry$ pip install coverage Collecting coverage Using cached…
Tarik Kdiry
  • 57
  • 1
  • 2
  • 8
3
votes
1 answer

Python Coverage - not covering function contents, just definition

I am using coverage.py to test my code coverage. My tests are passing, however, when I call coverage run -- [script].py -m [test_script].py and generate a report it indicates that
3
votes
2 answers

lcov remove option is not removing coverage data as expected

I'm using lcov to generate coverage reports. I have a tracefile (broker.info) with this content (relevant fragment shown): $ lcov -r…
fgalan
  • 11,732
  • 9
  • 46
  • 89
3
votes
1 answer

Jest/Istanbul coverage for a module that isn't loaded with require

There is foo module which contains lines that cannot be tested when it's loaded as Node.js module: if (typeof module !== 'object') { do.something(); // line shows as uncovered } ... This line cannot be normally tested with require('./foo')…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
3
votes
1 answer

Breaking the build in TeamCity if .NET Core unit tests running under Docker have code-coverage less than 90%

I have recently been looking at Docker, and how I can use TeamCity to run .NET Core unit tests in Docker containers as part of my build pipe-line. I add this as the final line in my Dockerfile to be able to run tests: ENTRYPOINT ["dotnet", "test",…
Steve_333
  • 133
  • 10
3
votes
3 answers

Command line way to generate HTML coverageReport in Jest

In Jest, is there a way from the command line to generate an HTML coverage report if it is not defined in the jest.config.js files? I only want to generate the HTML report some of the time rather than every time I run Jest. The only way I've been…
Ray Pierce
  • 59
  • 1
  • 1
  • 6
3
votes
1 answer

Angular 6 Code Coverage... how to exclude local library in code coverage of application?

I have an Angular workspace with the following basic structure: /projects -- /admin <-- angular application -- /core <-- library These were generated by running ng generate application admin and ng generate library core... fairly straight…
martzcodes
  • 404
  • 5
  • 16
3
votes
0 answers

Why is Jest reporting these lines in my async Node code as not covered by tests?

Jest is reporting 3 lines as not covered, though as far as I can tell the tests do test them. This is part of a much larger project so I put together a couple of (relatively) small files that illustrate the issue. The lines it reports uncovered…
Alex
  • 93
  • 8
3
votes
1 answer

Side effects of cobertura

After some efforts I finally get cobertura running correctly for my web application on a tomcat server. Everything seems fine until I committed it to the svn and hudson finished(failed) his work. Without this build script I would have never (or…
mheinzerling
  • 1,035
  • 1
  • 10
  • 31
3
votes
0 answers

How to use JENKINS Compare Coverage plugin to check pull request coverage comparing to base branch?

I'm using the plugin : github-pr-coverage-status-plugin to make pull request checks on the coverage on Sonar. This plugin enables to record coverage for master, and then compare test coverage of that pull request with the coverage recorded of master…
sirineBEJI
  • 1,170
  • 2
  • 14
  • 25
3
votes
0 answers

VSCode or Delve issue - Unable to test at all

I have two projects on GitHub (https://github.com/NlaakStudios) (gowaf and ezgo). Debugging and Testing with VSCode and Delve work perfectly with the gowaf repo using the default launch.json. It does not work with ezgo which is just the config from…
NlaakALD
  • 377
  • 2
  • 6
  • 16
3
votes
0 answers

Measuring integration test coverage of .NET Core app

I would like to measure integration test coverage of a ASP.NET Core application running in a Linux container. Tooling like coverlet works nicely when applied to a unit test project that links system under test directly, but does not seems to support…
Lukáš Lánský
  • 4,641
  • 3
  • 32
  • 48
3
votes
3 answers

Passing the null object from a test method

I have a class Class1, which has a constructor and few methods. For these methods I'm writing the unit test cases using MSTest. The class looks like this. class Class1 { Order order = new Order(); // there is an class Order public…
CrazyCoder
  • 2,194
  • 10
  • 44
  • 91
3
votes
1 answer

Throw exception in test method using MSTest

I'm using MSTest to write test cases for my application. I have a method where files are moved from one directory to another directory. Now when I run code coverage, it shows that the catch block is not covered in code coverage. This is my code as…
CrazyCoder
  • 2,194
  • 10
  • 44
  • 91