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
0 answers

Is possible run --code-coverage or similar command to run coverage during ng serve in Ionic/Angular app?

I need to registry coverage result during ng serve to retrieve coverage report without karma test. I know during karma it is possible but I need to registry this report in serve mode.
3
votes
0 answers

`clearPackageData` removes the files(.exec & .ec) which are required to generate the JaCoCo report: Android

I want to clear the app states after the execution of each test case, for that, I have added: testInstrumentationRunnerArguments clearPackageData: 'true'. But because of clearPackageData, when I run the command to generate a test coverage report it…
Kavita Patil
  • 1,784
  • 1
  • 17
  • 30
3
votes
3 answers

How to test http.post request with parameters in angular 9?

I am new at angular I have a service that calls HTTP post requests with some parameters. Now I want to test that service function in angular. My service part is import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable }…
3
votes
4 answers

Jest coverage in a node typescript project always returns empty

I am working on backend Typescript project where I am trying to get coverage report for unit test case. Jest returns empty coverage report in terminal as well as in html report stating nothing. I also tried with -- --coverage --watchAll=false but it…
muthu
  • 723
  • 10
  • 27
3
votes
0 answers

Emit a warning with Jest

I am wondering if Jest has an option for emitting a warning when thresholds are not met instead of an error? I haven't been able to find any documentation on the subject. For example in my old karma tester runner using Instanbul reporter I would do…
3
votes
1 answer

Retrieving chisel source description inside of treadle

I'm currently working on trying to add coverage to treadle. I was able to do so for the input LoFIRRTL code as follows: COVERAGE REPORT: + circuit Test_1 : + module Test_1 : + input in$a : UInt<1> + input in$b$0 : UInt<2> + input…
3
votes
2 answers

How to get the full code coverage on a Maven multi-modules project

Imagine a multi-modules Maven project, such as the following one: parent +- core +- main main is dependent on the core module. I now write a class CoreClass in core, with 2 methods: method1() and method2(). In core tests, I write a test class…
Romain Linsolas
  • 79,475
  • 49
  • 202
  • 273
3
votes
1 answer

Tracing Node.js program execution

I'd like to trace the execution path of an arbitrary Node.js program. Specifically, I'd like to run a program (server or script), and have some sort of block-level (function call, loop, if statement) trace of the execution. Constraints Output must…
wheresmycookie
  • 683
  • 3
  • 16
  • 39
3
votes
4 answers

Why is Jacoco Coverage Report for Branches saying if (a && b && c) is actually 6 branches?

My company has a requirement that we reach 90% test coverage for new code, and for Java code I am using gradle jacoco plugin which is nice; however, the branch coverage percentage is very difficult to improve to 90% when the number of branches…
codefactor
  • 1,616
  • 2
  • 18
  • 41
3
votes
2 answers

PIT Coverage generation minion exited abnormally

i see the following stacktrace when running the pitest gradle task in my project after adding all the required configurations in build.gradle. Can you please help me on this ? I'm using 1.5.1 version of the plugin. The changes have been done in…
3
votes
0 answers

How to get coverage percentage in jenkins pipeline

I am using cobertura to publish coverage report from xml file in the post section of a stage. I would like to also get the coverage percentage and send it in a mail inside post section. stage (publish){ steps{ ...... } post { …
3
votes
0 answers

Scoverage set up for a gradle multi module project issue

For a multi module project on Scala using gradle, there are integration tests in module A that call a method X from this module. This method in turn calls method Y from another module B. I'd expect both X and Y to get coverage but since Y is in a…
afelisatti
  • 2,770
  • 1
  • 13
  • 21
3
votes
1 answer

LINQ `Any` not covered by unit test

I've got this method: /// /// Moves piece to location, does not verify that this is a valid move /// /// public virtual void Move(Coordinate dest) { if (Board.IsPieceAtLocation(dest)) { …
ScottishTapWater
  • 3,656
  • 4
  • 38
  • 81
3
votes
0 answers

React-Native FlatList RenderItem Testing With Jest

I have developed Component UserContainer which uses FlatList I am able to test the FlatList test using Jest. Note I am not using Enzyme library for testing But don't know how to test renderItem={renderItem} const renderItem = ({ item }) => (
3
votes
1 answer

How to implement parallel pytesting with code coverage in Azure CI

I was able to implement parallel pytesting in Azure CI. See this repo for reference. But still code coverage is not working as expected. It is individually working, but it is not combining all tests coverage. Here is the Azure config file I am…