Questions tagged [test-coverage]
The test-coverage tag has no usage guidance.
77
questions
2
votes
3
answers
240
views
Covering a NO-OP Condition
I have a Java project where a coverage analysis tool is being used (SonarQube). It rightly declared that code similar to this was a potential performance issue (Encode.forJava would still be called ...
-1
votes
3
answers
206
views
Connection between code coverage and defects per KLOC
Most of the articles I read state that the average number of defects per KLOC is 10-15 (most of the data seems to come from Microsoft). How does that number correlate with code coverage?
If my project ...
-1
votes
3
answers
113
views
Code Coverage and Unit Tests nomenclature [closed]
About tests:
I have the following view on nomenclature:
Unit tests are the kind of testes where you have a function
ExtractBacon, where there is a function with an entry parameter Pig
and a return of ...
0
votes
3
answers
208
views
Test driven reduction of technical debt
Suppose you have been put in charge of an already existing project. As you are starting to familiarize yourself with the repository, you notice a few technical debt issues (insufficient test coverage, ...
2
votes
1
answer
192
views
Test coverage for various code logic permutations... Metadata/Artifacts in algorithm results to describe which case?
I'm sorry if the title is confusing, I don't know if what I am describing has a proper name so let me describe...
I have an algorithm which contains quite a bit of nested if/else if/else logic for ...
0
votes
0
answers
78
views
Unit test coverage and abundant glue code [duplicate]
How do I solve this riddle of contradicting "good practices" to properly cover my app with unit-tests?
These are principles I found about writing unit-tests:
Pyramid of testing says unit-...
0
votes
1
answer
64
views
The correct relationship between unit and end to end tests
I am writing tests for an algorithm that is built up of several consecutive stages. Each such stage has its own set of unit tests.
I want to check that the whole algorithm performs as expected, but am ...
2
votes
1
answer
160
views
How to evaluate the impact of change for a single line of code or a variable?
During unit testing it is possible to estimate the code coverage to see which share of the code base is covered by the tests.
For one part (the simple calculatable one) of a risk estimation we need to ...
1
vote
5
answers
248
views
Hypothetically if every scenario were covered by an end-to-end tests, would unit tests still have any value?
Note: I'm asking about the strategy behind unit / integration / end-to-end tests, not about classifying tests as one or the other.
More so in the past than present, it was expensive to write and run ...
-5
votes
1
answer
1k
views
Is it possible to derive a test suite to achieve 100% path coverage? [closed]
Here is an example with the function:
Examining this I believe that it is possible to achieve 100% path coverage.
My understanding of path coverage is that you need to design test cases such that ...
1
vote
2
answers
113
views
How important is the data to assess code coverage?
per the title how important is the data in assessing code coverage?
As background, let's say that you're given 20% of the entire dataset to help trace the different pathways each row of data goes ...
4
votes
4
answers
597
views
How to comprehensively test software that doesn't play well with testing?
I'm currently working in a project that aims to implement automatic testing of a software package. You can imagine this software is a bit like Excel in that it has a workspace that contains all the ...
38
votes
11
answers
10k
views
Unexpected Code Coverage Reduction
I am adding unit tests to some existing code which initially was not tested at all.
I have set up my CI system to fail builds where the code coverage percentage is reduced compared to previous build -...
8
votes
7
answers
2k
views
Rerun unit tests affected by change [closed]
Let's say we have a code base covered with big enough amount of unit tests. We make small change to the code and want to check if tests are still passing. Wouldn't it be great to be able to rerun just ...
5
votes
5
answers
8k
views
If 100% test coverage is possible
In thinking about formal verification techniques, you also need to have test coverage. But as that article shows, you can easily say you have "100% test coverage", but every test doesn't have any ...
-2
votes
1
answer
360
views
What is meant by "every branch" in testing coverage criteria?
I have generated the program graph of a method that contains an if condition and a for loop, and I need to generate test cases that covers "every branch". Would this include the for loop, given that ...
60
votes
7
answers
16k
views
Code coverage highlights unused methods - what should I do?
I have been tasked to increase code coverage of an existing Java project.
I noticed that the code coverage tool (EclEmma) has highlighted some methods that are never called from anywhere.
My initial ...
-1
votes
1
answer
216
views
How to Gain full Confidence in Pull Request builds
Having confidence means Pull Request builds (in Jenkins) will finally allow you to merge the code after a Pull request builds successfully and is reviewed. You're 100% confident that it can go into ...
3
votes
4
answers
958
views
Are short-circuiting paths considered for path coverage?
In a book Doron A. Peled, he states that "
path coverage does not subsume multiple condition coverage because you
can execute all the paths without exercising all the conditions.
But I believe ...
2
votes
2
answers
547
views
How is code coverage measured?
For many languages there are various tools which measure code coverage. But how exactly does this work?
I have some ideas, how this could work:
Do coverage tools just run the code in the debugger ...
7
votes
4
answers
1k
views
Are unit tests written purely to satisfy a code coverage figure technical debt?
For reasons lost in the mists of time, your project has a code coverage standard. Unfortunately, some new code has gone in which takes the coverage below this figure. John Doe is duly assigned to ...
6
votes
3
answers
7k
views
What is the advantage of instruction (byte code) coverage over line and branch coverage?
Our project uses Jacoco for code coverage metrics. Previously, we have checked the line and branch coverage against percentage values. However, the documentation also describes an "Instructions" level,...
0
votes
2
answers
629
views
How did software engineers test their code in 19xx? [closed]
There is a plethora of tools available for engineers to test their code these days. However, frameworks like Mocha.js came around only in 2011 with the ascent of NPM. So I wonder what were the ...
7
votes
4
answers
4k
views
Should one test generated code?
My team doesn't write tests for generated code (e.g. some POJOs). An engineer that I greatly respect recently wrote this on the subject:
Research over the past 10 years has revealed that generated ...
5
votes
3
answers
3k
views
How to test local/nested conditional logic branches and variables that cannot be easily manipulated?
It is easy enough to create unit tests for conditional blocks which follow the expected path, but it can sometimes be difficult to contrive data for sources/objects I do not directly control, (...
1
vote
2
answers
266
views
When writing a JUnit test for non-covered legacy code - how important is it to understand the original scenarios?
A Tech Lead in my team said:
We're going to use sonar on our (500KLoc) codebase so that everytime you do a commit, it will check the classes you've touched against the coverage goals. If you don't ...
6
votes
1
answer
129
views
What is the method to articulate the tradeoffs between short-fast mocked JUnit tests and slower Integration tests?
The assumption is that we're working on a large legacy Java codebase - with active ongoing development.
I had a team member say:
We should use lots of smaller JUnit tests that are focused on one ...
19
votes
1
answer
2k
views
Does it make sense to measure conditional coverage for Java 8 code?
I'm wondering whether measuring conditional code coverage by current tools for Java are not obsolete since Java 8 came up. With Java 8's Optional and Stream we can often avoid code branches/loops, ...
14
votes
6
answers
7k
views
Does Code Coverage improve code quality? [duplicate]
I am curious whether there are metrics on whether code coverage actually improves code quality? Any research studies?
If so, at what percent does it become a case of diminishing returns?
If not, why ...
2
votes
1
answer
2k
views
Should integration test coverage allow for lower unit test code coverage? [duplicate]
If a project has 30% coverage by unit tests, 40% due to integration tests, is it fair to say the total is 70% as so moderately well covered?
Or are unit tests only ever used as the standard test ...
0
votes
1
answer
166
views
Test coverage measurements
I have found several documents about statement and decision/branch coverage in testing, but these terms aren't clear for me.
There are two types of this problems, that you can see below.
Code:
...
2
votes
1
answer
176
views
How do we design a test approach for inexperienced testers?
We're in the process of shifting our datasource from Mongo to MS SQL Server. Our challenge is that we have two testers who are green. As a team, we're trying to work through the most sensible test ...
2
votes
0
answers
989
views
What is the difference between cyclomatic coverage and branch coverage?
While studying for my exam for software development I noticed that I couldn't give an example of cyclomatic coverage (the coverage reached through base path testing) that would satisfy the ...
-1
votes
1
answer
192
views
How many functional tests to write?
It is quite easy to cover your code by writing tests first using TDD and you know that when to stop once you implemented a feature.
For me it is trickier to decide how many functional tests to write ...
1
vote
0
answers
216
views
Rules of thumb for test coverage [closed]
In general it makes sense to me to unit test everything besides glue classes which have no logic. They often catch mistakes and code smells even at the time of writing let alone protecting you from ...
1
vote
2
answers
1k
views
Possible to get path coverage but not condition coverage or other way around?
I was wondering if it was possible to get path coverage(executing all paths) but not condition coverage? Also, how about the other way, condition coverage, but not path coverage? A concrete example ...
11
votes
1
answer
1k
views
When does it make sense to include test code in coverage?
Many coverage tools evaluate an entire project, including unit test code itself. In VS 2013, the Analyze Code Coverage/All Tests option includes test code in its report. OpenCover does so as well I ...
6
votes
2
answers
3k
views
Should I write automated unit tests that fail when the code changes?
Generally when writing automated unit tests (eg JUnit, Karma) I aim to:
cover all the boundary conditions
get a high level of coverage.
I heard someone say:
coverage and boundary conditions ...
6
votes
1
answer
14k
views
How does branch coverage handle loops?
I know how code coverage works in general, and I know what branch coverage is. But I can not seem to find an explanation for how branch coverage handles loops.
Does it work like path coverage? Where ...
2
votes
1
answer
3k
views
TDD: How to test domain model
When practicing TDD, how do you test a domain model? If you don't test, how do you account for code coverage? We want to have 100% coverage (or as much as possible), but despite hours of training ...
4
votes
1
answer
159
views
Reducing conditional code makes assessing coverage or debugging difficult
Working in Python, I've written a few utilities to assert pre-conditions and to re-interpret exceptions, and have found my code doesn't have so many branches.
I've also tried to move other code path ...
3
votes
1
answer
336
views
Code Coverage or Test Brevity?
I've been writing a lot of unit tests lately and have become somewhat obsessed with code coverage. However, I'm struggling justifying going for 100% code coverage, when so many tests would be a ...
0
votes
1
answer
101
views
What are the cons to excluding some code from coverage analysis?
I've recently become very interested in improving my project's test coverage. At this point, I have a submodule pretty thoroughly tested, but it's coverage is still pretty low because the tool is ...
65
votes
11
answers
14k
views
Does path coverage guarantee finding all bugs?
If every path through a program is tested, does that guarantee finding all bugs?
If not, why not? How could you go through every possible combination of program flow and not find the problem if one ...
1
vote
1
answer
840
views
how to unittest with thorough test coverage [duplicate]
I am trying to get into unit testing with python (though my question
is not specific to python).
I want to add a test for function I already have - I know I should do it
the other way round, but here ...
9
votes
7
answers
11k
views
How do you check that code has been covered automatically?
I am in the process of setting up a Bamboo server for some new projects for a push to TDD in a CI/CD workflow. Sure, unit testing is great, but only as log as it is there.
Now this might be better ...
0
votes
1
answer
365
views
Testing - How to test if you are actually testing the code?
I was thinking about unit tests and code coverage, and I came up with this thought:
It is possible to have 100% code coverage and not test 100% of your code.
For example:
function ...
0
votes
1
answer
269
views
What's good about statement coverage?
When it comes to code coverage, you often hear about the flaws of statement coverage criteria. We're told that statement does not take into account control structures and branches thereof, and is ...
20
votes
9
answers
5k
views
How do you unit-test code using graph structures?
I am writing (recursive) code that is navigating a dependency graph looks for cycles or contradictions in the dependencies. However, I am not sure how to approach unit testing this. The problem is ...
11
votes
2
answers
3k
views
Separate code coverage reports for unit and integration tests, or one report for both?
Should there be a separate code coverage report for unit and integration tests, or one code coverage report for both?
The thinking behind this is that code coverage allows us to make sure that our ...