home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / software / 5097 next >
Encoding:
Text File  |  1992-12-21  |  47.0 KB  |  1,125 lines

  1. Newsgroups: comp.software-eng
  2. Path: sparky!uunet!spool.mu.edu!sgiblab!munnari.oz.au!metro!usage!syacus!paulb
  3. From: paulb@syacus.acus.oz.au (Paul Bandler)
  4. Subject: Value of Code Coverage Analysis Metrics - Summary
  5. Message-ID: <1992Dec21.061509.25208@syacus.acus.oz.au>
  6. Organization: ACUS Australian Centre for Unisys Software, Sydney
  7. Date: Mon, 21 Dec 1992 06:15:09 GMT
  8. Lines: 1115
  9.  
  10.  
  11. Sender: news@lmpsbbs.comm.mot.com (Net News)
  12. Organization: Motorola Land Mobile Products Sector
  13. Lines: 55
  14. Nntp-Posting-Host: 145.16.3.73
  15.  
  16. In article <1992Dec14.072812.13689@syacus.acus.oz.au>, paulb@syacus.acus.oz.au (Paul Bandler) writes:
  17.  
  18. <preamble deleted>
  19.  
  20. |> I believe we have a tool to measure the %BFA 'Branch Flow Analysis' but
  21. |> of course the engineers are responsible for producing the test cases to 
  22. |> exercise the code.
  23. |> 
  24. |> I have 3 questions:-
  25. |> 
  26. |> 1)  Do people think that this is a valuable metric?
  27. |> 2)  Is it a cost effective excersize to get engineers to achieve a particular
  28. |>     %BFA as a completion criteria?
  29. |> 3)  What is a realistic %BFA to aim for?
  30. |> Paul Bandler
  31.  
  32. BFA is a valuable tool for testing. %BFA, as with all unitless numbers, is
  33. of a more dubious nature.
  34.  
  35. %BFA does not tell the person looking at it which paths were not tested
  36. and why. This is important because engineers could, subconsciously or
  37. otherwise, use their quota of untested branches to avoid testing the more
  38. complex/niggly areas of code.
  39.  
  40. The nature of the testing is also important - only if you are programming
  41. in an interpreted language where syntax must be checked by execution,
  42. is executing every line of code useful by itself. (You can
  43. run through every branch of a square root function but it won't
  44. test for what happens with a negative parameter. There is always a
  45. temptation to say that a line i++ 'passes because it increments i' without
  46. checking when it shouldn't.)
  47.  
  48. As to cost effectiveness this is so dependant upon the available tools,
  49. maintainance costs, whether or not testability was built into the code etc.
  50. that any global statement would be rash.
  51.  
  52. A realistic %BFA target is again dependant upon specific circumstances.
  53. I don't know if anyone has done any work to find out the %age of
  54. defects found, against testing coverage and time taken but I would
  55. be interested to find out. The benefits of higher percentages are not
  56. linear and certainly peaks.
  57.  
  58. Setting %BFA as a part of completion criteria is probably worthwhile but
  59. getting dogmatic about it is probably not. BFA is very useful for helping
  60. engineers see where more testing is required it is not that useful as an
  61. exam mark for the testing.
  62.  
  63. -- David
  64.  
  65. ========= All opinions are mine and not necessarily Motorola's ============
  66. =  @mail : David Alexander, Channel Tunnel Software, Motorola, Lyon Way,  =
  67. =                           Camberley (ZUK20), Surrey GU15 3QG, U.K.      =
  68. = Email : (Internet) davidal@comm.mot.com  Motorola X400-gateway : CDA004 =
  69. = Telephone : (office) +44 (0)276-413340   (home)+44 (0)276-24249         =
  70. ===========================================================================
  71.  
  72. Subject: >>>  Value of High Code Coverage Metrics in Testing - Request for Opinion
  73. Sender: usenet@news.eng.convex.com (news access account)
  74. Message-ID: <ssimmons.724336081@convex.convex.com>
  75. Date: Mon, 14 Dec 1992 12:28:01 GMT
  76. Nntp-Posting-Host: pixel.convex.com
  77. Organization: Engineering, CONVEX Computer Corp., Richardson, Tx., USA
  78. X-Disclaimer: This message was written by a user at CONVEX Computer
  79.               Corp. The opinions expressed are those of the user and
  80.               not necessarily those of CONVEX.
  81. Lines: 27
  82.  
  83.  
  84. Performing test coverage analysis on code is more of a good attitude than
  85. it is a silver bullet for removing bugs.  There is an old mgmt saying,
  86. "What is inspected is what gets done". 
  87.  
  88. > 1)  Do people think that this is a valuable metric?
  89.  
  90. Again, it improves the code but it does not remove all bugs. Design flaws
  91. about cases not being handled cannot be found.  Also, any code that uses data
  92. driven tables (e.g. finite state parsers) cannot be measured effectively. 
  93.  
  94. > 2)  Is it a cost effective excersize to get engineers to achieve a particular
  95. >    %BFA as a completion criteria?
  96.  
  97. Sure... if you have the time in the schedule and effective tools to do it. 
  98. Usually, it is best to have people do coverage analysis on their own code
  99. and have people who don't know the code test it for unanticipated conditions.
  100.  
  101. > 3)  What is a realistic %BFA to aim for?
  102.  
  103. Fairly low percentage of 50% is usually the maximum possible value.  Much 
  104. code is assertion testing.  However, every condition should be accounted. 
  105.  
  106. Thank you. 
  107.  
  108.  
  109.                         Steve Simmons
  110.  
  111. From comp.software-eng Wed Dec 16 08:41:18 1992
  112. Newsgroups: comp.software-eng
  113. Path: syacus!usage!metro!munnari.oz.au!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!claird
  114. From: claird@NeoSoft.com (Cameron Laird)
  115. Subject: Re: >>>  Value of High Code Coverage Metrics in Testing - Request for Opinion
  116. Organization: NeoSoft Communications Services -- (713) 684-5900
  117. Date: Mon, 14 Dec 1992 14:16:41 GMT
  118. Message-ID: <Bz96Bu.EBw@NeoSoft.com>
  119. References: <ssimmons.724336081@convex.convex.com>
  120. Lines: 31
  121.  
  122. In article <ssimmons.724336081@convex.convex.com> ssimmons@convex.com (Steve Simmons) writes:
  123.             .
  124.             .
  125.             .
  126. >> 2)  Is it a cost effective excersize to get engineers to achieve a particular
  127. >>    %BFA as a completion criteria?
  128. >
  129. >Sure... if you have the time in the schedule and effective tools to do it. 
  130. PARTICULARLY if you don't have time in the schedule.
  131. Try it; in my experience, people learn a lot from their
  132. first coverage exercises.  It's far better to learn
  133. those things *before* shipping the product.
  134. >Usually, it is best to have people do coverage analysis on their own code
  135. >and have people who don't know the code test it for unanticipated conditions.
  136. >
  137. >> 3)  What is a realistic %BFA to aim for?
  138. >
  139. >Fairly low percentage of 50% is usually the maximum possible value.  Much 
  140. >code is assertion testing.  However, every condition should be accounted. 
  141. 85%.  Serious.
  142.             .
  143.             .
  144.             .
  145. If you're lucky, Brian Marick will tune in to this
  146. conversation; he's the gentleman with the most ex-
  147. perience and insight on this topic.
  148. -- 
  149.  
  150. Cameron Laird
  151. claird@Neosoft.com (claird%Neosoft.com@uunet.uu.net)    +1 713 267 7966
  152. claird@litwin.com (claird%litwin.com@uunet.uu.net)      +1 713 996 8546
  153.  
  154. To: paulb@syacus.acus.oz.au
  155. Subject: Re: Value of High Code Coverage Metrics in Testing - Request for Opinion
  156. Newsgroups: comp.software-eng
  157. References: <1992Dec14.072812.13689@syacus.acus.oz.au>
  158. Status: RO
  159.  
  160. In comp.software-eng you write:
  161. >I have 3 questions:-
  162.  
  163. >1)  Do people think that this is a valuable metric?
  164. >2)  Is it a cost effective excersize to get engineers to achieve a particular
  165. >    %BFA as a completion criteria?
  166. >3)  What is a realistic %BFA to aim for?
  167. >Paul Bandler
  168.  
  169. Brian Marick has written a couple of papers that answer your questions;
  170. they are "Experience with the Cost of Test Suite Coverage Measures" and
  171. "Three Ways to Improve Your Testing".  They discuss various types of code
  172. coverage, and how useful they are.  Both are available by anonymous ftp
  173. from <something>.cs.uiuc.edu.  Unfortunately, I don't remember what the
  174. <something> is; however, you could mail him at marick@cs.uiuc.edu, and
  175. I'm sure he'd be glad to tell you how to get them.
  176.  
  177.                             --Samuel Bates
  178.                               samuel@cs.wisc.edu
  179.  
  180. Date: Mon, 14 Dec 92 09:25:53 PST
  181. From: Todd Huffman <huffman@yoko.STAT.ORST.EDU>
  182. Message-Id: <9212141725.AA21682@yoko>
  183. To: paulb%syacus.acus.OZ.AU
  184. Subject: Re: Value of High Code Coverage Metrics in Testing - Request for Opinion
  185. Newsgroups: comp.software-eng
  186. In-Reply-To: <1992Dec14.072812.13689@syacus.acus.oz.au>
  187. Organization: Oregon State University Math Department
  188. Cc: 
  189. Status: RO
  190.  
  191. Branch coverage metrics are quite useful, and they are accepted by the
  192. software engineering community at large as being useful.  The only
  193. consideration to work out is efficiency of getting these numbers and
  194. cost vs. benefit for the organization.
  195.  
  196. I heard a good comment from a seminar by Tsun Chow (he's at ATT
  197. Naperville, Ill.).  If your line coverage is not 100% then you
  198. are shipping software that has never been executed.  Sounds risky!
  199. If your branch coverage is not 100% then you are  shipping software
  200. with branches that have never been taken.  Also risky.
  201.  
  202. My experience is that this sort of metric collection must be automated
  203. if it is to be cost effective.  It must be done at the UNIT test stage.
  204. Something 80 - 100% would be useful.  If programmers do not have to
  205. get 80% coverage, then you will have some of them release barely tested 
  206. modules when the schedule gets tight.
  207.  
  208. This sort of metric must be put in perspective with the whole QA program.
  209. Even with 100% coverage there will remain bugs.  I think it is important
  210. to track bugs discovered by the integration/system test group per module.
  211. Then you will know which programmers have released buggy code to test.
  212. The 80% (or whatever you choose) branch coverage level should prevent
  213. the very bad code from being release and subsequent code churning.
  214.  
  215. Here is a reference where test coverage metrics are used quite well--
  216. "Experience in Testing the Motif Interface", Jason Su, Paul Ritter
  217. (they're at Hewlett-Packard).  March 1991, IEEE Software.
  218. That whole issue is devoted to testing--other articles are also good.
  219.  
  220. Thats all for my 2 cents worth.
  221. Todd Huffman
  222.  
  223.  
  224. Received: from hotel.mitre.org.w151_sparc by milner.mitre.org.w151_sparc (4.1/SMI-4.1)
  225.     id AA16924; Mon, 14 Dec 92 12:06:24 EST
  226. Date: Mon, 14 Dec 92 12:06:24 EST
  227. From: drodman@milner.mitre.org (David B Rodman)
  228. Message-Id: <9212141706.AA16924@milner.mitre.org.w151_sparc>
  229. To: paulb@syacus.acus.oz.au
  230. Subject: A  Brian Marick testing case study (long)
  231. Status: RO
  232.  
  233.  
  234. ------- Forwarded Message
  235.  
  236. Replied: Mon, 06 Jul 92 16:28:06 -0400
  237. Replied: "Brian Marick <marick@cs.uiuc.edu> "
  238. Received: from mwunix.mitre.org by milner.mitre.org.w151_sparc (4.1/SMI-4.1)
  239.     id AA10005; Mon, 6 Jul 92 16:25:27 EDT
  240. Return-Path: <marick@cs.uiuc.edu>
  241. Received: from m.cs.uiuc.edu by mwunix.mitre.org (5.61/SMI-2.2)
  242.     id AA07558; Mon, 6 Jul 92 16:23:11 -0400
  243. Received: by m.cs.uiuc.edu id AA15701
  244.   (5.64+/IDA-1.3.4 for vecellio@milner.mitre.org); Mon, 6 Jul 92 15:26:15 -0500
  245. Date: Mon, 6 Jul 92 15:26:15 -0500
  246. From: Brian Marick <marick@cs.uiuc.edu>
  247. Message-Id: <9207062026.AA15701@m.cs.uiuc.edu>
  248. To: vecellio@milner.mitre.org
  249. Cc: vecellio@milner.mitre.org
  250. In-Reply-To: Gary Vecellio's message of Mon, 06 Jul 92 16:20:32 -0400 <9207062020.AA09946@milner.mitre.org.w151_sparc>
  251. Subject: A testing case study (long)
  252.  
  253.            A CASE STUDY IN COVERAGE TESTING
  254.                  Brian Marick
  255.              Testing Foundations
  256.  
  257. Abstract
  258.  
  259. I used a C coverage tool to measure the quality of its own test suite.
  260. I wrote new tests to improve the coverage of a 2600-line segment of
  261. the tool.  I then reused and extended those tests for the next
  262. release, which included a complete rewrite of that segment.  The
  263. experience reinforced my beliefs about coverage-based testing:
  264.  
  265. 1.  A thorough test suite should achieve nearly 100% feasible coverage.
  266. 2.  Adding tests for additional coverage can be cheap and effective.
  267. 3.  To be effective, testing should not be a blind attempt to achieve
  268.     coverage.  Instead, use coverage as a signal that points to weakly-tested
  269.     parts of the specification.
  270. 4.  In addition to suggesting new tests, coverage also tells you when existing
  271.     tests aren't doing what you think, a common problem.
  272. 5.  Coverage beyond branch coverage is worthwhile.
  273. 6.  Even with thorough testing, expect documentation, directed
  274.     inspections, beta testing, and customers to find bugs, especially design
  275.     and specification bugs.
  276.  
  277. The Generic Coverage Tool
  278.  
  279. GCT is a freeware coverage tool for C programs, based on the GNU C
  280. compiler.   It measures these kinds of coverage:
  281. - - branch coverage (every branch must be taken in both directions)
  282. - - multi-condition coverage (in 'if (a && b)', both subexpressions must
  283.   evaluate to true and false).
  284. - - loop coverage (require loop not to be taken, to be traversed exactly once,
  285.   and traversed more than once)
  286. - - relational coverage (require tests for off-by-one errors)
  287. - - routine entry and call point coverage.
  288. - - race coverage (extension to routine coverage for multiprocessing)
  289. - - weak mutation coverage (a research technique)
  290.  
  291. (For more, see [Marick92].)
  292.  
  293. The tool comes with a large regression test suite, developed in
  294. parallel with the code, using a "design a little, test a little, code
  295. a little" approach, much like that described in [Rettig91].  About
  296. half the original development time was spent in test construction (with, I
  297. believe, a corresponding reduction in the amount of frantic debugging
  298. when problems were found by users - though of course there was some of
  299. that).  Most of the tests are targetted to particular subsystems, but
  300. they are not unit tests.  That is, the tests invoke GCT and deduce
  301. subsystem correctness by examining GCT's output.  Only a few routines
  302. are tested in isolation using stubs - that's usually too expensive.  When
  303. needed, test support code was built into GCT to expose its internal
  304. state.
  305.  
  306. In early releases, I had not measured the coverage of GCT's own test
  307. suite.  However, in planning the 1.3 release, I decided to replace the
  308. instrumentation module with two parallel versions.  The original
  309. module was to be retained for researchers; commercial users would use
  310. a different module that wouldn't provide weak mutation coverage but
  311. would be superior in other ways.  Before redoing the implementation, I
  312. wanted the test suite to be solid, because I knew a good test suite
  313. would save implementation time.
  314.  
  315. Measuring Coverage
  316.  
  317. I used branch, loop, multi-condition, and relational coverage.  I'm
  318. not convinced weak mutation coverage is cost-effective.  Here were my
  319. initial results for the 2617 lines of code I planned to replace.
  320. (The count excludes comments, blank lines, and lines including only
  321. braces.) 
  322.  
  323. BINARY BRANCH INSTRUMENTATION (402 conditions total)
  324. 47 (11.69%) not satisfied.
  325. 355 (88.31%) fully satisfied.
  326.  
  327. SWITCH INSTRUMENTATION (90 conditions total)
  328. 14 (15.56%) not satisfied.
  329. 76 (84.44%) fully satisfied.
  330.  
  331. LOOP INSTRUMENTATION (24 conditions total)
  332. 5 (20.83%) not satisfied.
  333. 19 (79.17%) fully satisfied.
  334.  
  335. MULTIPLE CONDITION INSTRUMENTATION (390 conditions total)
  336. 56 (14.36%) not satisfied.
  337. 334 (85.64%) fully satisfied.
  338.  
  339. OPERATOR INSTRUMENTATION (45 conditions total)    ;; This is relational coverage
  340. 7 (15.56%) not satisfied.
  341. 38 (84.44%) fully satisfied.
  342.  
  343. SUMMARY OF ALL CONDITION TYPES (951 total)
  344. 129 (13.56%) not satisfied.
  345. 822 (86.44%) fully satisfied.
  346.  
  347. These coverage numbers are consistent with what I've seen using black
  348. box unit testing combined with judicious peeks into the code.  (See
  349. [Marick91].)  I do not target coverage in my test design; it's more
  350. important to concentrate on the specification, since many important
  351. faults will be due to omitted code [Glass81].
  352.  
  353. When the uncovered conditions were examined more closely (which took
  354. less than an hour), it was clear that the tests were more thorough
  355. than appears from the above.  The 129 uncovered conditions broke down
  356. as follows:
  357.  
  358. 28 were impossible to satisfy (sanity checks, loops with fixed bounds
  359. can't be executed 0 times, and so on).
  360.  
  361. 46 were support code for a feature that was never implemented (because
  362. it turned out not to be worthwhile); these were also impossible to
  363. exercise. 
  364.  
  365. 17 were from temporary code, inserted to work around excessive stack
  366. growth on embedded systems.  It was always expected to be removed, so
  367. was not tested.
  368.  
  369. 24 were due to a major feature, added late, that had never had
  370. regression tests written for it.
  371.  
  372. 14 conditions corresponded to 10 untested minor features.
  373.  
  374. All in all, the test suite had been pleasingly thorough.
  375.  
  376. New Tests Prior to the Rewrite
  377.  
  378. I spent 4 hours adding tests for the untested major feature.  I was
  379. careful not to concentrate on merely achieving coverage, but rather on
  380. designing tests based on what the program was supposed to do.  Coverage
  381. is seductive - like all metrics, it is only an approximation of what's
  382. important.  When "making the numbers" becomes the prime focus, 
  383. they're often achieved at the expense of what they're supposed to measure.
  384.  
  385. This strategy paid off.  I found a bug in handling switches within
  386. macros.  A test designed solely to achieve coverage would likely have
  387. missed the bug.  (That is, the uncovered conditions could have
  388. been satisfied by an easy - but inadequate - test.)
  389.  
  390. There was another benefit.  Experience writing these tests clarified
  391. design changes I'd planned to make anyway.  Writing tests often has
  392. this effect.  That's why it's good to design tests (and write user
  393. documentation) as early as possible.
  394.  
  395. I spent two more hours testing the minor features.  I did not write
  396. tests for features that were only relevant to weak mutation.
  397.  
  398. Branch coverage discovered one pseudo-bug: dead code.  A particular
  399. special case check was incorrect.  It was testing a variable against
  400. the wrong constant.  This check could never be true, so the special
  401. case code was never executed.  However, the special case code turned
  402. out to have the same effect as the normal code, so it was removed.
  403. (This fault was most likely introduced during earlier maintenance.)
  404.  
  405. At this point, tests written because of multi-condition, loop, and relational
  406. coverage revealed no bugs.  My intuitive feel was that the tests
  407. were not useless - they checked situations that might well have led to
  408. failures, but didn't.
  409.  
  410. I reran the complete test suite overnight and rechecked coverage the
  411. next day.  One test error was discovered; a typo caused the test to
  412. miss checking what it was designed to test.  Rechecking took 1/2 hour.
  413.  
  414. Reusing the Test Suite
  415.  
  416. The rewrite of the instrumentation module was primarily a
  417. re-implementation of the same specification.  All of the test suite
  418. could be reused, and there were few new features that required new
  419. tests.  (I did go ahead and write tests for the weak mutation features
  420. I'd earlier ignored.)  About 20% of the development time was spent on
  421. the test suite (including new tests, revisions to existing tests, and
  422. a major reorganization of the suite's directory structure and
  423. controlling scripts).
  424.  
  425. The regression test suite found minor coding errors; they always do,
  426. in a major revision like this.  It found no design flaws.  Rewriting
  427. the internal documentation (code headers) did.  (After I finish code,
  428. I go back and revise all the internal documentation.  The shift in
  429. focus from producing code to explaining it to an imaginary audience
  430. invariably suggests improvements, usually simplifications.  Since I'm
  431. a one-man company, I don't have the luxury of team code reads.)
  432.  
  433. The revised test suite achieved 96.47% coverage.  Of 37 unsatisfied
  434. conditions:
  435.  
  436. 27 were impossible to satisfy.
  437. 2 were impossible to test portably (GNU C extensions).
  438. 2 were real (though minor) omissions.
  439. 1 was due to a test that had been misplaced in the reorganization.
  440. 5 were IF tests that had been made redundant by the rewrite. They were removed.
  441.  
  442. It took an hour to analyse the coverage results and write the needed
  443. tests.  They found no bugs.  Measuring the coverage for the augmented
  444. test suite revealed that I'd neglected to add one test file to the
  445. test suite's controlling script.
  446.  
  447. Other Tests
  448.  
  449. The 1.3 release also had other features, which were duly tested.  For
  450. one feature, relational operator coverage forced the discovery of a
  451. bug.  A coverage condition was impossible to satisfy because the code
  452. was wrong.  I've found that loop, multi-condition, and relational
  453. operator coverage are cheap to satisfy, once you've satisfied branch
  454. coverage.  This bug was severe enough that it alone justified the time
  455. I spent on coverage beyond branch.
  456.  
  457. Impossible conditions due to bugs happen often enough that I believe
  458. goals like "85% coverage" are a mistake.  The problem with such goals
  459. is that you don't look at the remaining 15%, deciding, without
  460. evidence, that they're either impossible or not worth satisfying. It's
  461. better - and not much more expensive - to decide each case on its
  462. merits.
  463.  
  464. What Testing Missed
  465.  
  466. Three bugs were discovered during beta testing, one after release (so
  467. far).  I'll go into some detail, because they nicely illustrate the
  468. types of bugs that testing tends to miss.
  469.  
  470. The first bug was a high level design omission.  No testing technique
  471. would force its discovery. ("Make sure you instrument routines with a
  472. variable number of arguments, compile them with the GNU C
  473. compiler, and do that on a machine where GCC uses its own copy of
  474. <varargs.h>.")  This is exactly the sort of bug that beta testing is
  475. all about.
  476.  
  477. Fixing the bug required moderately extensive changes and additions,
  478. always dangerous just before a release.  Sure enough, the fix
  479. contained two bugs of its own (perhaps because I rushed to meet a
  480. self-imposed deadline).
  481.  
  482. - - The first was a minor design omission.  Some helpful code was added
  483. to warn GCC users iff they need to worry about <varargs.h>. This code
  484. made an assumption that was violated in one case.  Coverage would not
  485. force a test to detect this bug, which is of the sort that's fixed by
  486. changing
  487.  
  488.     if (A && B)
  489.  
  490. to
  491.  
  492.     if (A && B && C)
  493.  
  494. It would have been nice if GCT would have told me that "condition C,
  495. which you should have but don't, was never false", but this is more
  496. than a coverage tool can reasonably be expected to do.  I found the
  497. bug by augmenting the acceptance test suite, which consists of
  498. instrumenting and running several large "real" programs.  (GCT's test
  499. suite contains mostly small programs.)  Instrumenting a new real
  500. program did the trick.
  501.  
  502. - - As part of the original fix, a particular manifest constant had to
  503. be replaced by another in some cases.  I missed one of the cases.  The
  504. result was that a few too few bytes of memory were allocated for a
  505. buffer and later code could write past the end.  Existing tests did
  506. indeed force the bytes to be written past the end; however, this
  507. didn't cause a failure on my development machine (because the memory
  508. allocator rounds up).  It did cause a failure on a different machine.
  509. Memory allocation bugs, like this one and the next, often slip past
  510. testing.
  511.  
  512. The final bug was a classic: freeing memory that was not supposed to
  513. be freed.  None of the tests caused the memory to be reused after
  514. freeing, but a real program did.  I can envision an implementable type
  515. of coverage that would force detection of this bug, but it seems as
  516. though a code-read checklist ought to be better.  I use such a
  517. checklist, but I still missed the bug.
  518.  
  519.  
  520. References
  521.  
  522. [Rettig91]    Marc Rettig, "Practical Programmer:  Testing Made
  523.     Palatable", CACM, May, 1991.
  524.  
  525. [Marick91]    Brian Marick, "Experience with the Cost of Different
  526.     Coverage Goals for Testing", Pacific Northwest Software Quality
  527.     Conference, 1991.
  528.  
  529. [Marick92]    Brian Marick, "A Tutorial Introduction to GCT", 
  530.     "Generic Coverage Tool (GCT) User's Guide", "GCT Troubleshooting",
  531.     "Using Race Coverage with GCT", and "Using Weak Mutation Coverage with GCT",
  532.     Testing Foundations, 1992.
  533.  
  534. [Glass81]    Robert L. Glass. "Persistent Software Errors", Transactions
  535.     on Software Engineering", vol. SE-7, No. 2, pp. 162-168,
  536.     March, 1981.
  537.  
  538. Brian Marick, marick@cs.uiuc.edu, uiucdcs!marick
  539. Testing Foundations:  Consulting, Training, Tools.
  540.  
  541.  
  542.  
  543. ------- End of Forwarded Message
  544.  
  545.  
  546.  
  547.  
  548. From drodman@milner.mitre.org@usage.csd.unsw.oz Tue Dec 15 04:05:25 1992
  549. From: drodman@milner.mitre.org (David B Rodman)
  550. Message-Id: <9212141702.AA16882@milner.mitre.org.w151_sparc>
  551. To: paulb@syacus.acus.oz.au
  552. Subject: Value of High Code Coverage Metrics in Testing
  553. Cc: drodman@milner.mitre.org
  554. Status: RO
  555.  
  556. >I have 3 questions:-
  557.  
  558. >1)  Do people think that this is a valuable metric?
  559. >2)  Is it a cost effective excersize to get engineers to achieve a particular
  560. >    %BFA as a completion criteria?
  561. >3)  What is a realistic %BFA to aim for?
  562.  
  563. 1) (is a valuable metric?) 
  564.     My personal opinion is that it is. However, it must be taken within the 
  565. context of a comprehensive test program and not as a sole metric. Also the metric
  566. should not be abused by the development engineers as an excuse for thought! What I 
  567. mean by this is the drive to achieve high branch coverage sometimes causes 
  568. engineers to design simple tests which get high coverage but result in missing errors.
  569.  
  570.     example pseudo code:
  571.         if value greater than  0.0 then
  572.             next value = 1/sqr(value) /comment/ *error* should be sqroot()
  573.         end_if
  574.  
  575. simple test cases would be 1, -1 and maybe 0.0, However all of these test cases 
  576. produce the same result as the correct code, leaving what could be a very hard 
  577. to find error to s/w integration.
  578.  
  579. 2) (Is it a cost effective excersize)
  580.     I do not have any numbers available, but I have a copy of "Brian Marick 
  581. <marick@cs.uiuc.edu> " "A CASE STUDY IN COVERAGE TESTING" (previously posted) 
  582. He has done some measurements based on his own programming habits. I will forward as
  583. a seperate posting.
  584.  
  585. 3) (What is a realistic %BFA to aim for?)
  586.     I would make it 100%, then make exceptions on a case by case basis.
  587. Exception handling code, spurious error code and other generally unproducable 
  588. actions are good cadidates for exceptions.
  589.  
  590.  
  591. I have some interest in other opinions/answers to your questions. Could you 
  592. please return/post a summary of resonses to your questions.
  593. Thanks
  594.  
  595.  
  596. David Rodman
  597. MITRE Corporation
  598. Mclean, VA
  599. drodman@mitre.org
  600.  
  601. From Michael_P._Kirby.roch803@xerox.com@usage.csd.unsw.oz Tue Dec 15 04:02:29 1992
  602. Date:     Mon, 14 Dec 1992 08:04:38 PST
  603. From: Michael_P._Kirby.roch803@xerox.com
  604. Subject: Re: Value of High Code Coverage Metrics in Tes
  605. To: paulb@syacus.acus.oz.au
  606. Cc: kirby.roch803@xerox.com
  607. Reply-To: Michael_P._Kirby.roch803@xerox.com
  608. Message-Id: <"14-Dec-92 11:04:38 EST".*.Michael_P._Kirby.roch803@Xerox.com>
  609. Status: RO
  610.  
  611. Received: by milo.isdl (4.1/SMI-4.0) id AA07499; Mon, 14 Dec 92 11:04:33 EST
  612.  
  613. Paul,
  614.  
  615. Do you guys already practice software inspections?  From my experience it is 
  616. very good practice to hold formal software inspections.  There are many good
  617. articles that describe both the process and the results
  618.  
  619. Russle, "Experience withInspection in Ultralarge Scale Developments," IEEE Software, 
  620.     January 1991
  621.  
  622. Fagan, "Design and code inspections to reduce errors in program development," IBM
  623.     Systems Journal, No.3, 1976, pp.184-211.
  624.  
  625. Fagan, "Advances in Software Inspections," IEEE Transactions on Software Engineering,
  626.     July 1986, pp744-751
  627.  
  628. These are just a couple.
  629.  
  630. I have talked to several people who say that once good inspections are in place,
  631. unit testing becomes unnessesary.  System testing, of course, is still very important.
  632.  
  633. As for BFA, I don't have any experience with it, but I'm of the philosophy that
  634. testing by exaustion is not feasable.  Therefore BFA only tells you how close you are
  635. to a reasonable test coverage.  Perhaps an alternative approach is to apply some kind
  636. of reliability growth modeling. (John Musa has written several books on the subject).
  637. Here the idea is that we test based on a customer operational profile.  (i.e. we
  638. test features, not code path's).  We then model the number of "failures" that a customer
  639. will see.  From this we can set a threshold of failures/unit time that is "acceptable"
  640. to the customer.  At this point the product is ready to ship.  
  641.  
  642. After shipping the product we can do realiability modeling to deterimine how
  643. good our integration testing really was.
  644.  
  645. These are just other ideas.  
  646.  
  647. Mike Kirby
  648. Xerox Corp
  649. E-mail: kirby.roch803@xerox.com
  650.  
  651. From lawrence@uk.ate.slb.com@usage.csd.unsw.oz Wed Dec 16 04:07:02 1992
  652. Date: Tue, 15 Dec 92 14:11:24 GMT
  653. From: lawrence%ukfca1@sj.ate.slb.com
  654. Message-Id: <9212151411.AA07293@juniper.uk.ate.slb.com>
  655. To: paulb@syacus.acus.oz.au
  656. Subject: Code coverage metrics.
  657. Status: RO
  658.  
  659.  
  660. Paul,
  661.  
  662. At the current site where I am working the Sun utility 'tcov' is used
  663. to give a simple metric for test coverage.
  664.  
  665. As I understand it tcov gives a form of BFA based on statements.
  666.  
  667. The powers that be here have decided that all code will be tested to
  668. give a minimum of 90% coverage.
  669.  
  670. I don't know how the figure 90% was reached, I suspect it just sounded good.
  671.  
  672. All the same, looking at the history of software engineering at this
  673. site, including a "test coverage" criterion in the engineering standards
  674. has been beneficial.
  675.  
  676. The main benefit has been that engineers now think about coverage when
  677. designing the tests.
  678.  
  679. (Yes, unit testing is done by the engineers here).
  680.  
  681. The down side is that the engineers are aware of the (probably arbitrary)
  682. coverage figure when designing/coding and this affects their efforts.
  683. In particular, engineers are encouraged to introduce a lot of executable
  684. code (rather than making it table/data driven) since they know that this
  685. will increase the amount of code which will be exercised with "easy" test
  686. cases, and the amount of code which is hard to test will be relatively
  687. small. If they can get the "hard" test cases into the 10% which doesn't
  688. have to be tested then it makes their job easier/quicker.
  689.  
  690. Of course the brownie points are awarded for speed rather than quality.
  691.  
  692. I hope this is of interest to you.
  693.  
  694. I would appreciate a summary of what you learn. maybe you could mail
  695. me as I don't always have access to the news feed.
  696.  
  697. (PS: I forgot to mention - this is on respnse to Article 6755 in
  698.  comp.software-eng)
  699.  
  700. Glenn
  701. < lawrence@uk.ate.slb.co >
  702.  
  703. From philip@mama.research.canon.oz Tue Dec 15 18:02:17 1992
  704. Date: Tue, 15 Dec 92 17:45:29 EST
  705. From: philip@research.canon.oz.au (Philip Craig)
  706. Message-Id: <9212150645.AA01582@denis.research.canon.oz.au>
  707. To: paulb@syacus.acus.oz.au
  708. Subject: Re: Value of High Code Coverage Metrics in Testing - Request for Opinion
  709. Newsgroups: comp.software-eng
  710. In-Reply-To: <1992Dec14.072812.13689@syacus.acus.oz.au>
  711.  
  712. Organization: Canon Information Systems Research Australia
  713. Status: RO
  714.  
  715. In article <1992Dec14.072812.13689@syacus.acus.oz.au> you write:
  716. >I have been tasked with the Quality Assurance of a Product Development.  One of
  717. >the metrics I have been asked to measure is the 'Branch Flow Analysis' (BFA)
  718. >percentage achieved during unit and system testing.  i.e. How much of the
  719. >potential paths through the code is actually excersized during these
  720. >testing phases.
  721. >
  722. >I believe we have a tool to measure the %BFA but of course the engineers are
  723. >responsible for producing the test cases to excersize the code.
  724. >
  725. >I have 3 questions:-
  726. >
  727. >1)  Do people think that this is a valuable metric?
  728. >2)  Is it a cost effective excersize to get engineers to achieve a particular
  729. >    %BFA as a completion criteria?
  730. >3)  What is a realistic %BFA to aim for?
  731.  
  732. Hi Paul,
  733.  
  734. I'm responsible for some testing here at CISRA, so I'd be thrilled to get
  735. copies of any replies that you get (apart from me-too ones!).
  736.  
  737. what are you using to measure BFA? GCT?
  738.  
  739. It seems to me that it can be valuable objective quantitative metric,
  740. particularly if the people writing the test suites are *not* initially
  741. striving for a particular BFA percentage.
  742.  
  743. That is, have them write tests to test functionality, function points, or
  744. whatever, and then look at the BFA percentage. This can tell you whether
  745. a good portion of the functionality is being tested (where good depends
  746. very much on how much confidence you need to have in the product).
  747.  
  748. Have I ever seen you at soccer? I know some ACUS people go. Are you the
  749. Paul who goes?
  750. -- 
  751. Philip Craig philip@research.canon.oz.au Phone:+61 2 8052951 Fax:+61 2 8052929
  752. "Now bid me run, and I will strive with things impossible -
  753. yea, and get the better of them."
  754. -- W. Shakespeare, JULIUS CAESAR
  755.  
  756. From marick@hal.cs.uiuc.edu@usage.csd.unsw.oz Sat Dec 19 04:33:12 1992
  757. Date: Fri, 18 Dec 1992 11:30:36 -0600
  758. From: Brian Marick <marick@hal.cs.uiuc.edu>
  759. Message-Id: <199212181730.AA00537@hal.cs.uiuc.edu>
  760. To: paulb@syacus.acus.oz.au
  761. Subject: Re: Value of High Code Coverage Metrics in Testing - Request for Opinion
  762. Newsgroups: comp.software-eng
  763. References: <1992Dec14.072812.13689@syacus.acus.oz.au>
  764. Status: RO
  765.  
  766. This may be of interest:
  767.  
  768.            A CASE STUDY IN COVERAGE TESTING
  769.                  Brian Marick
  770.              Testing Foundations
  771.  
  772. Abstract
  773.  
  774. I used a C coverage tool to measure the quality of its own test suite.
  775. I wrote new tests to improve the coverage of a 2600-line segment of
  776. the tool.  I then reused and extended those tests for the next
  777. release, which included a complete rewrite of that segment.  The
  778. experience reinforced my beliefs about coverage-based testing:
  779.  
  780. 1.  A thorough test suite should achieve nearly 100% feasible coverage.
  781. 2.  Adding tests for additional coverage can be cheap and effective.
  782. 3.  To be effective, testing should not be a blind attempt to achieve
  783.     coverage.  Instead, use coverage as a signal that points to weakly-tested
  784.     parts of the specification.
  785. 4.  In addition to suggesting new tests, coverage also tells you when existing
  786.     tests aren't doing what you think, a common problem.
  787. 5.  Coverage beyond branch coverage is worthwhile.
  788. 6.  Even with thorough testing, expect documentation, directed
  789.     inspections, beta testing, and customers to find bugs, especially design
  790.     and specification bugs.
  791.  
  792. The Generic Coverage Tool
  793.  
  794. GCT is a freeware coverage tool for C programs, based on the GNU C
  795. compiler.   It measures these kinds of coverage:
  796. - branch coverage (every branch must be taken in both directions)
  797. - multi-condition coverage (in 'if (a && b)', both subexpressions must
  798.   evaluate to true and false).
  799. - loop coverage (require loop not to be taken, to be traversed exactly once,
  800.   and traversed more than once)
  801. - relational coverage (require tests for off-by-one errors)
  802. - routine entry and call point coverage.
  803. - race coverage (extension to routine coverage for multiprocessing)
  804. - weak mutation coverage (a research technique)
  805.  
  806. (For more, see [Marick92].)
  807.  
  808. The tool comes with a large regression test suite, developed in
  809. parallel with the code, using a "design a little, test a little, code
  810. a little" approach, much like that described in [Rettig91].  About
  811. half the original development time was spent in test construction (with, I
  812. believe, a corresponding reduction in the amount of frantic debugging
  813. when problems were found by users - though of course there was some of
  814. that).  Most of the tests are targetted to particular subsystems, but
  815. they are not unit tests.  That is, the tests invoke GCT and deduce
  816. subsystem correctness by examining GCT's output.  Only a few routines
  817. are tested in isolation using stubs - that's usually too expensive.  When
  818. needed, test support code was built into GCT to expose its internal
  819. state.
  820.  
  821. In early releases, I had not measured the coverage of GCT's own test
  822. suite.  However, in planning the 1.3 release, I decided to replace the
  823. instrumentation module with two parallel versions.  The original
  824. module was to be retained for researchers; commercial users would use
  825. a different module that wouldn't provide weak mutation coverage but
  826. would be superior in other ways.  Before redoing the implementation, I
  827. wanted the test suite to be solid, because I knew a good test suite
  828. would save implementation time.
  829.  
  830. Measuring Coverage
  831.  
  832. I used branch, loop, multi-condition, and relational coverage.  I'm
  833. not convinced weak mutation coverage is cost-effective.  Here were my
  834. initial results for the 2617 lines of code I planned to replace.
  835. (The count excludes comments, blank lines, and lines including only
  836. braces.) 
  837.  
  838. BINARY BRANCH INSTRUMENTATION (402 conditions total)
  839. 47 (11.69%) not satisfied.
  840. 355 (88.31%) fully satisfied.
  841.  
  842. SWITCH INSTRUMENTATION (90 conditions total)
  843. 14 (15.56%) not satisfied.
  844. 76 (84.44%) fully satisfied.
  845.  
  846. LOOP INSTRUMENTATION (24 conditions total)
  847. 5 (20.83%) not satisfied.
  848. 19 (79.17%) fully satisfied.
  849.  
  850. MULTIPLE CONDITION INSTRUMENTATION (390 conditions total)
  851. 56 (14.36%) not satisfied.
  852. 334 (85.64%) fully satisfied.
  853.  
  854. OPERATOR INSTRUMENTATION (45 conditions total)    ;; This is relational coverage
  855. 7 (15.56%) not satisfied.
  856. 38 (84.44%) fully satisfied.
  857.  
  858. SUMMARY OF ALL CONDITION TYPES (951 total)
  859. 129 (13.56%) not satisfied.
  860. 822 (86.44%) fully satisfied.
  861.  
  862. These coverage numbers are consistent with what I've seen using black
  863. box unit testing combined with judicious peeks into the code.  (See
  864. [Marick91].)  I do not target coverage in my test design; it's more
  865. important to concentrate on the specification, since many important
  866. faults will be due to omitted code [Glass81].
  867.  
  868. When the uncovered conditions were examined more closely (which took
  869. less than an hour), it was clear that the tests were more thorough
  870. than appears from the above.  The 129 uncovered conditions broke down
  871. as follows:
  872.  
  873. 28 were impossible to satisfy (sanity checks, loops with fixed bounds
  874. can't be executed 0 times, and so on).
  875.  
  876. 46 were support code for a feature that was never implemented (because
  877. it turned out not to be worthwhile); these were also impossible to
  878. exercise. 
  879.  
  880. 17 were from temporary code, inserted to work around excessive stack
  881. growth on embedded systems.  It was always expected to be removed, so
  882. was not tested.
  883.  
  884. 24 were due to a major feature, added late, that had never had
  885. regression tests written for it.
  886.  
  887. 14 conditions corresponded to 10 untested minor features.
  888.  
  889. All in all, the test suite had been pleasingly thorough.
  890.  
  891. New Tests Prior to the Rewrite
  892.  
  893. I spent 4 hours adding tests for the untested major feature.  I was
  894. careful not to concentrate on merely achieving coverage, but rather on
  895. designing tests based on what the program was supposed to do.  Coverage
  896. is seductive - like all metrics, it is only an approximation of what's
  897. important.  When "making the numbers" becomes the prime focus, 
  898. they're often achieved at the expense of what they're supposed to measure.
  899.  
  900. This strategy paid off.  I found a bug in handling switches within
  901. macros.  A test designed solely to achieve coverage would likely have
  902. missed the bug.  (That is, the uncovered conditions could have
  903. been satisfied by an easy - but inadequate - test.)
  904.  
  905. There was another benefit.  Experience writing these tests clarified
  906. design changes I'd planned to make anyway.  Writing tests often has
  907. this effect.  That's why it's good to design tests (and write user
  908. documentation) as early as possible.
  909.  
  910. I spent two more hours testing the minor features.  I did not write
  911. tests for features that were only relevant to weak mutation.
  912.  
  913. Branch coverage discovered one pseudo-bug: dead code.  A particular
  914. special case check was incorrect.  It was testing a variable against
  915. the wrong constant.  This check could never be true, so the special
  916. case code was never executed.  However, the special case code turned
  917. out to have the same effect as the normal code, so it was removed.
  918. (This fault was most likely introduced during earlier maintenance.)
  919.  
  920. At this point, tests written because of multi-condition, loop, and relational
  921. coverage revealed no bugs.  My intuitive feel was that the tests
  922. were not useless - they checked situations that might well have led to
  923. failures, but didn't.
  924.  
  925. I reran the complete test suite overnight and rechecked coverage the
  926. next day.  One test error was discovered; a typo caused the test to
  927. miss checking what it was designed to test.  Rechecking took 1/2 hour.
  928.  
  929. Reusing the Test Suite
  930.  
  931. The rewrite of the instrumentation module was primarily a
  932. re-implementation of the same specification.  All of the test suite
  933. could be reused, and there were few new features that required new
  934. tests.  (I did go ahead and write tests for the weak mutation features
  935. I'd earlier ignored.)  About 20% of the development time was spent on
  936. the test suite (including new tests, revisions to existing tests, and
  937. a major reorganization of the suite's directory structure and
  938. controlling scripts).
  939.  
  940. The regression test suite found minor coding errors; they always do,
  941. in a major revision like this.  It found no design flaws.  Rewriting
  942. the internal documentation (code headers) did.  (After I finish code,
  943. I go back and revise all the internal documentation.  The shift in
  944. focus from producing code to explaining it to an imaginary audience
  945. invariably suggests improvements, usually simplifications.  Since I'm
  946. a one-man company, I don't have the luxury of team code reads.)
  947.  
  948. The revised test suite achieved 96.47% coverage.  Of 37 unsatisfied
  949. conditions:
  950.  
  951. 27 were impossible to satisfy.
  952. 2 were impossible to test portably (GNU C extensions).
  953. 2 were real (though minor) omissions.
  954. 1 was due to a test that had been misplaced in the reorganization.
  955. 5 were IF tests that had been made redundant by the rewrite. They were removed.
  956.  
  957. It took an hour to analyse the coverage results and write the needed
  958. tests.  They found no bugs.  Measuring the coverage for the augmented
  959. test suite revealed that I'd neglected to add one test file to the
  960. test suite's controlling script.
  961.  
  962. Other Tests
  963.  
  964. The 1.3 release also had other features, which were duly tested.  For
  965. one feature, relational operator coverage forced the discovery of a
  966. bug.  A coverage condition was impossible to satisfy because the code
  967. was wrong.  I've found that loop, multi-condition, and relational
  968. operator coverage are cheap to satisfy, once you've satisfied branch
  969. coverage.  This bug was severe enough that it alone justified the time
  970. I spent on coverage beyond branch.
  971.  
  972. Impossible conditions due to bugs happen often enough that I believe
  973. goals like "85% coverage" are a mistake.  The problem with such goals
  974. is that you don't look at the remaining 15%, deciding, without
  975. evidence, that they're either impossible or not worth satisfying. It's
  976. better - and not much more expensive - to decide each case on its
  977. merits.
  978.  
  979. What Testing Missed
  980.  
  981. Three bugs were discovered during beta testing, one after release (so
  982. far).  I'll go into some detail, because they nicely illustrate the
  983. types of bugs that testing tends to miss.
  984.  
  985. The first bug was a high level design omission.  No testing technique
  986. would force its discovery. ("Make sure you instrument routines with a
  987. variable number of arguments, compile them with the GNU C
  988. compiler, and do that on a machine where GCC uses its own copy of
  989. <varargs.h>.")  This is exactly the sort of bug that beta testing is
  990. all about.
  991.  
  992. Fixing the bug required moderately extensive changes and additions,
  993. always dangerous just before a release.  Sure enough, the fix
  994. contained two bugs of its own (perhaps because I rushed to meet a
  995. self-imposed deadline).
  996.  
  997. - The first was a minor design omission.  Some helpful code was added
  998. to warn GCC users iff they need to worry about <varargs.h>. This code
  999. made an assumption that was violated in one case.  Coverage would not
  1000. force a test to detect this bug, which is of the sort that's fixed by
  1001. changing
  1002.  
  1003.     if (A && B)
  1004.  
  1005. to
  1006.  
  1007.     if (A && B && C)
  1008.  
  1009. It would have been nice if GCT would have told me that "condition C,
  1010. which you should have but don't, was never false", but this is more
  1011. than a coverage tool can reasonably be expected to do.  I found the
  1012. bug by augmenting the acceptance test suite, which consists of
  1013. instrumenting and running several large "real" programs.  (GCT's test
  1014. suite contains mostly small programs.)  Instrumenting a new real
  1015. program did the trick.
  1016.  
  1017. - As part of the original fix, a particular manifest constant had to
  1018. be replaced by another in some cases.  I missed one of the cases.  The
  1019. result was that a few too few bytes of memory were allocated for a
  1020. buffer and later code could write past the end.  Existing tests did
  1021. indeed force the bytes to be written past the end; however, this
  1022. didn't cause a failure on my development machine (because the memory
  1023. allocator rounds up).  It did cause a failure on a different machine.
  1024. Memory allocation bugs, like this one and the next, often slip past
  1025. testing.  [Later note:  tools like Cahill's dbmalloc/Sentinal and Pure's
  1026. Purify can move some of these bugs from the realm of the untestable to
  1027. the realm of the testable.  I now use dbmalloc, and it would have
  1028. caught this bug.]
  1029.  
  1030. The final bug was a classic: freeing memory that was not supposed to
  1031. be freed.  None of the tests caused the memory to be reused after
  1032. freeing, but a real program did.  I can envision an implementable type
  1033. of coverage that would force detection of this bug, but it seems as
  1034. though a code-read checklist ought to be better.  I use such a
  1035. checklist, but I still missed the bug.
  1036.  
  1037.  
  1038. References
  1039.  
  1040. [Rettig91]    Marc Rettig, "Practical Programmer:  Testing Made
  1041.     Palatable", CACM, May, 1991.
  1042.  
  1043. [Marick91]    Brian Marick, "Experience with the Cost of Different
  1044.     Coverage Goals for Testing", Pacific Northwest Software Quality
  1045.     Conference, 1991.
  1046.  
  1047. [Marick92]    Brian Marick, "A Tutorial Introduction to GCT", 
  1048.     "Generic Coverage Tool (GCT) User's Guide", "GCT Troubleshooting",
  1049.     "Using Race Coverage with GCT", and "Using Weak Mutation Coverage with GCT",
  1050.     Testing Foundations, 1992.
  1051.  
  1052. [Glass81]    Robert L. Glass. "Persistent Software Errors", Transactions
  1053.     on Software Engineering", vol. SE-7, No. 2, pp. 162-168,
  1054.     March, 1981.
  1055.  
  1056. Brian Marick, marick@cs.uiuc.edu, uiucdcs!marick
  1057. Testing Foundations:  Consulting, Training, Tools.
  1058.  
  1059.  
  1060. From pilchuck!phred!timf@uunet.uu.net@usage.csd.unsw.oz Fri Dec 18 12:33:31 1992
  1061. >From pilchuck!phred!timf@uunet.uu.net Wed Dec 16 09:15:43 1992
  1062. Message-Id: <m0n2CFL-000FCGC@data-io.com>
  1063. Date: Wed, 16 Dec 92 17:15:43 -0800
  1064. To: pilchuck!paulb@syacus.acus.oz.au
  1065. Subject: Re: Value of High Code Coverage Metrics in Testing - Request for Opinion
  1066. From: pilchuck!phred!timf@uunet.uu.net (Tim Farley)
  1067. Status: RO
  1068.  
  1069. This is probably getting too you really late since our news
  1070. here is really slow, but...
  1071.  
  1072. I think code coverage is a valuable metric, as long as it's
  1073. not you're only measurement of test completeness. As long as
  1074. you're doing other things to assure that you have adequate
  1075. data coverage for your tests, and can show functional coverage
  1076. as well, you should come out okay. If you haven't already, you
  1077. might want to check through the IEEE standard for measures to
  1078. produce reliable software (982.2-1988) for some other coverage
  1079. measurements.
  1080.  
  1081. Depending on the tool you're using to calculate code coverage
  1082. it can be very cost effective. The tool that I've used (TekDB
  1083. with CCA) prints a variety of reports to show exactly what code
  1084. has been tested and what hasn't. For engineers, this makes it
  1085. really easy to get the coverage up since all you do is run some
  1086. tests, generate the report, see what you haven't hit, then add
  1087. some more tests for these. We usually start the engineers off
  1088. with the high level test cases developed from the requirements
  1089. specifications and design documents, have them run through those
  1090. and check the coverage, then add in additional tests for what
  1091. hasn't been hit. It's not difficult, and if time has already been
  1092. scheduled for the engineer to do testing, it doesn't really add
  1093. anymore time (assuming a reasonable estimate for testing was
  1094. given) and can actually decrease the amount of time if they aren't
  1095. following any method with their testing.
  1096.  
  1097. I saw someone else posted something that said that 50% or so was
  1098. a good target. We set our target at 95%, with the expectation
  1099. that anything less than 100% had to be include a description of
  1100. why the remaining code had not been tested. Saying you didn't have
  1101. enough time wasn't accepted. They probability of that code being
  1102. executed, and the severity of a defect in the functionality
  1103. directly supported by that code, had to be included.
  1104.  
  1105. We always got at least 95% coverage, usually higher. With our
  1106. products, turning on the unit and running very basic functions
  1107. got about 60-70% coverage. You could get up to 90% or so with
  1108. the basic error and boundary conditions. The rest were usually
  1109. very rare hardware faults detected by the software. (I should
  1110. add that these were all test and measurement devices with
  1111. embedded software, in case you're wondering.)
  1112.  
  1113. I don't know what kind of devices you're working on. I'm currently
  1114. working on medical devices which have a lot more error detection
  1115. software and redundant systems, and I'm not sure what it would take
  1116. to get the same amount of coverage. However, I will set 100% as
  1117. the goal and anything less than that requiring a complete description
  1118. (which would still have to be approved).
  1119.  
  1120. What development environment are you working with? Just curious.
  1121.  
  1122. Tim Farley
  1123. Sr. SQA Engineer
  1124.  
  1125.