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

C++ code coverage tool running on command line

I use code coverage tool for writing unit testing cases. I have a code coverage tool but only have to do everything through its GUI interface. Ideally I'd like to get a tool that is able to produce a text output (.diff is the best) on individual…
Sherwood
3
votes
1 answer

How does Typescript ESDoc measure comment coverage?

I am writing in Angular4 and Typescript with the esdoc-coverage-plugin and esdoc-typescript-plugin. In my codebase, every method, class, and member have a comment block in this form: /** @method methodName * @desc method description * @param…
Matt
  • 51
  • 3
3
votes
0 answers

Code coverage with behat

We want to use the most current PHP_CodeCoverage API (https://github.com/sebastianbergmann/php-code-coverage) in our project. To be sure it's really the case we just made an addtional script in bin/behat-coverage #!/usr/bin/env php …
Juri Sinitson
  • 1,445
  • 1
  • 14
  • 18
3
votes
2 answers

Testing Object.hasOwnProperty

I have a code implementation that iterates over an object's properties. for (const prop in obj) { propsMap[prop] = prop; } But as is states, my IDE (WebStorm) adviced me to add a property check using obj.hasOwnProperty(prop) to avoid iterating…
Supamiu
  • 8,501
  • 7
  • 42
  • 76
3
votes
0 answers

Unit testing a function containing setTimeout

I have a function containing setTimeouts. I am trying to do unit testing but on the code coverage report it is always showing that the code inside the setTimeout is not executing.Here is the code. var func = function(str, type) { var t1 =…
3
votes
1 answer

Is code coverage for all existing test cases?

I have a doubt regarding code coverage. Consider the below scenario, If I am having the method Sample() with some parameters and I wrote say example 10 test cases for that method. While running code coverage, if a part of a code (say for example an…
Praveen
  • 831
  • 7
  • 15
3
votes
1 answer

Measuring python coverage at runtime

Is it possible to measure python code coverage at runtime and view the results as they are generated? I tried using coverage but couldn't find an option that would help. My initial experiments show that the .coverage file isn't saved to until the…
mattjegan
  • 2,724
  • 1
  • 26
  • 37
3
votes
1 answer

Visual Studio gives partial code coverage for new initializers

I'm using Visual Studio 2015 Update 3. I am failing to get 100% code coverage on this simple Unit Test: TEST_METHOD(New) { int* test = new int(4); //shows the line as partially covered int* test2 = new int; //shows line as 100%…
meneldal
  • 1,717
  • 1
  • 21
  • 30
3
votes
0 answers

What is the right balance for logging, commenting and test cases when coding?

One thing I have noticed about when I code is that commenting, logging and writing test cases takes me out of any flow I am in and slows down my coding speed. So I am wondering if I do it too much/more than necessary. If I am using a debug logger,…
Gorlan
  • 115
  • 1
  • 9
3
votes
1 answer

How to properly configure CodeCov for a C++ w/ CMake project in TravisCI?

I was trying to configure CodeCov on my GitHub repo with TravisCI. Since my repo is in C++ and I used CMake already, I essentially copy-pasted the after_success label of this example into my .travis.yml file: after_success: # Creating report -…
Carles Araguz
  • 1,157
  • 1
  • 17
  • 37
3
votes
0 answers

Missing files with code coverage

I have a project that I compile with the intel toolchain. All the .f90 files are compiled to corresponding .o files in the bin directory. When I use the codecov utility I get an HTML with the list of covered files. However that list is missing a…
Manfredo
  • 1,760
  • 4
  • 25
  • 53
3
votes
1 answer

How to use Mockito properly on Static methods wrapped inside non-static methods?

so I'm trying to use Mockito on a method that has a static method in it. The reason is I cannot use PowerMock so I wrapped the method under non-static method. public class WrapperUtil { public String getURLContent(String path) throws…
E.D
  • 43
  • 7
3
votes
1 answer

Best way to measure code coverage for python without checking every imported module

I am in the process of trying to integrate code coverage into our development pipeline, and we are having a hard time using nosetest to accurately estimate our code coverage due to the fact that it also checks coverage for each of our imported…
AndrewD
  • 75
  • 7
3
votes
2 answers

Missing certain GCDA files after test execution

I'm currently facing an issue with generating .gcda files for coverage data of a static library. I can get coverage data for most files, but not all. I'll refer to the object file with the missing coverage data as X. Some things to note: I have…
3
votes
0 answers

Android gradle test coverage exclude (pojo) classes?

I am running test coverage for android UI tests (androidTest) using ./gradlew createDevDebugCoverageReport. The report however contains classes of which I don't need coverage, such as pojo classes and external libraries. 1) Is there a way to tell…
1 2 3
99
100