Click here to Skip to main content
15,889,867 members

Survey Results

Do you use Code Coverage tools?

Survey period: 9 May 2022 to 16 May 2022

A critical tool or an unnecessary critic?

OptionVotes% 
Yes, always344.30
When it makes sense, yes.8310.51
Sometimes. It really depends.668.35
Rarely.10112.78
No, never.24230.63
I don't know what a Code Coverage tool is26433.42



 
General:doh: I think but i don't use it. Pin
Hermin Useini10-May-22 9:15
Hermin Useini10-May-22 9:15 
GeneralIdk what is it? Pin
Hermin Useini10-May-22 9:22
Hermin Useini10-May-22 9:22 
GeneralCan't Afford One Pin
BernardIE531710-May-22 1:39
BernardIE531710-May-22 1:39 
GeneralRe: Can't Afford One Pin
Jacquers10-May-22 7:25
Jacquers10-May-22 7:25 
GeneralUnit Tests + Sonarqube Pin
Jacquers9-May-22 21:37
Jacquers9-May-22 21:37 
GeneralRe: Unit Tests + Sonarqube Pin
Sander Rossel10-May-22 21:06
professionalSander Rossel10-May-22 21:06 
GeneralRe: Unit Tests + Sonarqube Pin
Jacquers10-May-22 21:18
Jacquers10-May-22 21:18 
GeneralRe: Unit Tests + Sonarqube Pin
jpoggio11-May-22 20:55
jpoggio11-May-22 20:55 
GeneralNo, coverage is pretty useless Pin
Sander Rossel9-May-22 20:45
professionalSander Rossel9-May-22 20:45 
GeneralRe: No, coverage is pretty useless Pin
Kirk 1038982110-May-22 9:49
Kirk 1038982110-May-22 9:49 
GeneralRe: No, coverage is pretty useless Pin
Sander Rossel11-May-22 10:01
professionalSander Rossel11-May-22 10:01 
GeneralRe: No, coverage is pretty useless Pin
trønderen11-May-22 13:42
trønderen11-May-22 13:42 
GeneralRe: No, coverage is pretty useless Pin
Sander Rossel11-May-22 20:09
professionalSander Rossel11-May-22 20:09 
GeneralRe: No, coverage is pretty useless Pin
trønderen12-May-22 6:01
trønderen12-May-22 6:01 
Sander Rossel wrote:
Partial classes can't be defined across assemblies. You're basically creating a single class, but split up over multiple files, so those files need to be in the same assembly.
So? In the days of executable files, rather than assemblies, the test code resided in the same executable as the application code. No difference.

In one of my earlier jobs, we had extensive discussions whether to remove test code from the system to be released, or to leave it in there. The tradition was to leave it in: When a customer reported a problem, we could ask him to turn on the switch generating test logs for analyzing the error. This had been very useful at several earlier occasions, and we decided to keep it in, even though it significantly increased total code size. After that, we made use of the test code several times while I was still with the company.

Now there is test code and test code. You obviously do not ship to the customer procedures for testing hundreds of borderline cases, or the complete cartesian product of the values of five different parameters. What you ship to the customer is test procedures for environmental conditions (including file system and network), verifying data structure consistency etc.

If you decide to leave parts of (or all) the test code out of the distribution, then you leave out that source file from the assembly and rebuild. True enough: You are then delivering a different binary from that where the complete set of tests were made (which was one of the concerns that made us leave the test code in). This is more relevant in a language where you manipulate pointers and memory allocation directly; pointer problems are far less frequent in C# than in e.g. plain C. The great majority of code bugs occur at the logical level, independent of physical location and addresses, and will be detected even if the binaries are not perfectly identical. (No module testing is done in a distribution binary!)

So, rather than making everything public so you can test it, as was suggested, you add a partial class (possibly with partial methods, if the test strategy requires the application code to call into the test procedures - but you would usually try to avoid that). That will give test procedures - and noone else - controlled access to private elements they need, and the test procedures do not gain access to 'everything else'.

For returning to the subject line contents: Especially with interpreted languages that are not even syntax checked at build time, coverage is essential. I have, both in code I wrote myself and in libraries developed by co-workers, had fatal crashes due to syntax errors ... in error handling procedures. Making sure that your tests provoke all possible errors (and the impossible ones as well) in all flavors so that the entire error handling has been at least syntactically checked may be quite difficult and you may have to resort to mockup errors, but do make sure that you test all error handling procedures thoroughly!

Coverage tools sometimes give you surprises: If you are not familiar with them, you might not believe the figures they report, the first time you use them. Most of us has a lot of code that has never been tested. For compiled languages, you at least can assume that the syntax is correct, but you forget to test all the 'else' clauses, several of the switch alternatives, etc.

So I strongly disagree with the subject line.
GeneralRe: No, coverage is pretty useless Pin
Sander Rossel14-May-22 21:32
professionalSander Rossel14-May-22 21:32 
GeneralRe: No, coverage is pretty useless Pin
Kirk 1038982111-May-22 16:12
Kirk 1038982111-May-22 16:12 
GeneralRe: No, coverage is pretty useless Pin
Sander Rossel11-May-22 20:10
professionalSander Rossel11-May-22 20:10 
GeneralRe: No, coverage is pretty useless Pin
Kirk 1038982112-May-22 2:50
Kirk 1038982112-May-22 2:50 
GeneralRe: No, coverage is pretty useless Pin
Sander Rossel12-May-22 2:55
professionalSander Rossel12-May-22 2:55 
GeneralNo, but need/want to. Pin
ergohack9-May-22 4:47
ergohack9-May-22 4:47 
GeneralRe: No, but need/want to. Pin
RickZeeland9-May-22 8:07
mveRickZeeland9-May-22 8:07 
GeneralWhen I have to Pin
Nemanja Trifunovic9-May-22 2:11
Nemanja Trifunovic9-May-22 2:11 
GeneralNo Pin
Slacker0079-May-22 0:48
professionalSlacker0079-May-22 0:48 
GeneralHad to google! Pin
CHill608-May-22 22:29
mveCHill608-May-22 22:29 
GeneralAlways - The SPICE is vital to automotive travel Pin
den2k888-May-22 22:01
professionalden2k888-May-22 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.