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

Azure DevOps build don't fail when coverage is below target with dotnet test

I have a build pipeline in Azure DevOps for a ASP.NET Core app, and a want use it with a criteria to approve a pull requests. steps: - script: dotnet restore displayName: 'Run command: dotnet restore' - script: > …
3
votes
0 answers

Why Jest 24.8 Coverage produce coverage === 0

PASS ../parser/test/flatten-user-flow-shortcuts.spec.ts PASS ../parser/test/flow-spliterators.spec.ts PASS ../parser/test/circles1.spec.js PASS ../parser/test/circles.spec.ts PASS ../parser/test/replace-basic-flows.spec.ts PASS …
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
3
votes
2 answers

Why is a method call shown as not covered when the code within the method is covered with emma?

I am writing a unit test to check that a private method will close a stream. The unit test calls methodB and the variable something is null The unit test doesn't mock the class on test The private method is within a public method that I am…
Craig Angus
3
votes
2 answers

how to include multiple code coverage's in the pipeline

I have an entity framework .net core application as a backend and .net core react app for the front-end. I am trying to setup azure pipelines for this project. While I am setting the pipeline for .net core react app I am running the library tests…
3
votes
1 answer

How to add unit test coverage to SonarQube? Using Azure-DevOps Pipeline

I'm trying to add the code coverage to sonarqube, the tests are included and executed but percentage of coverage is 0.0. In my pipeline I got "Prepare analysis on SonarQube" and the project key well configured in the additional Properties I put…
delfosk9
  • 73
  • 1
  • 9
3
votes
0 answers

How to instrument angular 6 project for code coverage using istanbul

I want to only instrument my angular 6 project source code (ts files). As I don't have any unit test cases, so I'm not able to use the angular cli inbuilt code coverage features. The instrumented code will be running against selenium based…
Anshul
  • 31
  • 3
3
votes
0 answers

PyCharm's code coverage not working due to Windows drive letters

I have a computer that has a C and D drive, where PyCharm, Python and the source code are installed on the D drive. I'm using Pipenv with PIPENV_VENV_IN_PROJECT set to enabled so that also ends up in the D drive. Despite all this, when running with…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
3
votes
1 answer

Pytest tests are showing up in code coverage report

When running pytest with python -m pytest --cov=. --cov-report html:coverage After the coverage report is generated my tests show up in the code coverage report as being 100% covered as shown below I've attempted to move tests into its own folder,…
clbx
  • 154
  • 2
  • 15
3
votes
2 answers

Is it possible to display Jacoco Coverage report on Jenkins dashboard?

I have jenkins file which has publishHTML method to generate report with .html file of jacoco result. Is it possible to display that report on dashboard like 'Test Trend Result' ?
dicle
  • 1,122
  • 1
  • 12
  • 40
3
votes
1 answer

Coverage shows too less percentage for Django test

i'm currently testing my django (2.1.0) application with some api-unit-tests. I used the django rest framework(3.9.0) to build a login. For this i use code like this: class LogoutTest(APITestCase): def test_login_post_unauth(self): …
user50548
  • 81
  • 7
3
votes
2 answers

How can i improve Codeception Code Coverage speed

Currently we have written some unit test for our php laravel 5.5 application using codeception. just for additional info, our laravel code base have around 200k LOC. For normal unit test run, we noticed that it is really fast in which we can get…
AlamHo
  • 193
  • 1
  • 3
  • 12
3
votes
1 answer

Xcode - Strange Code Coverage of Swift Computed Property

I have enabled code coverage for my unit tests, but for one struct I can't quite hit 100%, even though I believe I am testing all possible code paths. My struct has a computed property defined as: var nativeSize: CGSize { if rotated { …
Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
3
votes
0 answers

Lcov Coverage Innacurate

I am using lcov (version 1.14) and cobertura to generate a coverage analysis on our C++ code. (gcc version 4.9) After modifying the code, the code coverage went down inexplicably. Although we did not touch or remove any tests. For example, line…
ZeusCoder
  • 101
  • 2
3
votes
1 answer

SonarQube not displaying test code coverage of Ruby on Rails project

I have a Ruby on Rails project that I want to display test coverage in SonarQube. The project is built with Jenkins which sends the results to SonarQube. Unit tests are run with rspec and code coverage is calculated with SimpleCov. SonarQube…
gomisha
  • 2,587
  • 3
  • 25
  • 33
3
votes
2 answers

How can I generate HTML code coverage reports with new cabal?

Running stack test --coverage generates a nice HTML report showing what lines your test suite covers. How can I achieve the same thing using cabal new-test? I'm able to pass --enable-coverage to generate a .tix file but I'm not sure what to run on…
MaxGabriel
  • 7,617
  • 4
  • 35
  • 82