Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [test-coverage]

The tag has no usage guidance.

4
votes
7answers
196 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 ...
4
votes
5answers
767 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
1answer
84 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 ...
59
votes
7answers
12k 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
1answer
83 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
4answers
226 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 ...
1
vote
2answers
130 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 ...
6
votes
4answers
671 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 ...
3
votes
3answers
1k 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
2answers
609 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 ...
4
votes
4answers
1k 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 ...
4
votes
3answers
577 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
2answers
133 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
1answer
85 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
1answer
983 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, ...
12
votes
6answers
4k 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 ...
1
vote
1answer
706 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 ...
-1
votes
1answer
94 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: ...
3
votes
1answer
120 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 ...
1
vote
0answers
331 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
1answer
120 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 ...
0
votes
0answers
464 views

Bringing in unit test code with Mocking Frameworks in an established ASP.NET C# software application

Here is the information about my development environment: MongoDB 3.0.0 MongoDB C# Driver Version 1.7.0.4714 Microsoft Visual Studio Professional 2013 .NET Framework 4.0 We are about to do our ...
1
vote
0answers
99 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
2answers
259 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 ...
6
votes
1answer
707 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
2answers
2k 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 ...
3
votes
1answer
6k 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
1answer
1k 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
1answer
141 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 ...
4
votes
1answer
182 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
1answer
63 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 ...
63
votes
11answers
10k 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
1answer
629 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 ...
7
votes
7answers
6k 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 ...
1
vote
1answer
326 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
1answer
134 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 ...
18
votes
7answers
3k 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 ...
10
votes
2answers
2k 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 ...
6
votes
2answers
392 views

Is it ok to write “extra” unit tests?

My understanding of how TDD should work is that you write a failing test for the next bit of functionality you want to add to a function or object, code until the test passes and then write the next ...
-9
votes
1answer
470 views

How does code coverage work? [closed]

Specifically, what is contained inside code coverage data (.nccov or xml file) and how is an html report generated by this? Does the coverage data not include the actual percentage of code covered? Is ...
2
votes
2answers
9k views

What is “condition testing” (as defined by the ISTQB Syllabus) actually good for? [duplicate]

I am currently checking through the syllabus for the ISTQB "Technical Test Analyst" certification. This syllabus (henceforth called "TTA syllabus") contains a chapter dedicated to "condition testing" (...
2
votes
1answer
3k views

equals and hashcode methods autogenerated, is it always a good practice?

Preamble: Let's say I aim to cover all my classes with test coverage. Despite the common opinion (expecially in Java community) to "not pay too much attention to Cyclomatic Complexity (CC) and code ...
4
votes
5answers
7k views

How to unit test a missing case in a switch statement where all cases are true

I often use enum types in my code with a switch to apply logic to each type. In these cases it's important that each enum has code implemented. For example; public enum eERROR { REQUIRED, ...
1
vote
1answer
1k views

Does condition coverage subsume edge coverage?

I'm a little bit confused about code coverage criteria; especially condition and edge coverage. As stated in this book, edge coverage does not subsume condition coverage; BUT my lecture material ...
3
votes
5answers
7k views

Best practice for code coverage of empty interface methods

Given a class that implements an interface, but does not need all of the methods implemented, what is the best practice for unit testing this class with respect to code coverage? - or is it considered ...
11
votes
10answers
2k views

Any tools/suggestions on how to refute code coverage quality argument

Now I know people could consider this question duplicate or asked many times, in which case I would appreciate a link to relevant questions with answer to my question. I have been recently in ...
3
votes
1answer
125 views

Verification for value of test standards

We are currently developing a concept for our tests standards. Up until now, we don't have standards. All we do is to tell the developer to write tests. Now we have the following basic idea: We will ...
3
votes
1answer
9k views

Condition coverage for If(A && B) - measuring the input or code exercised?

I have been studying condition coverage for last few days. In a book "The Art of Software Testing" they highlight that it does not assure decision coverage, because for example IF(A && B) ...
0
votes
1answer
166 views

What the white box testers create test cases against?

I'm wondering, what are the white box testers using to create test cases? The actual code? Some kind of diagrams? I mean, if I am given a task to create test cases for complete branch coverage, is it ...
7
votes
5answers
10k views

Is path coverage stronger than condition coverage?

I have encountered (even in literature) two contradicting opinions related to path vs condition coverage (not branch or edge!). Some say Path coverage is stronger than the condition coverage, some say ...