Review: When Should One Stop Testing Software?¶
Citation
- Dalal, S. R., & Mallows, C. L. (1988). When should one stop testing software? Journal of the American Statistical Association, 83(403), 872–879.
- DOI
Abstract¶
We derive an optimal rule for stopping the testing of a module of software prior to release, based on the trade-off between the cost of continued testing and the expected losses due to any bugs that remain in the released code. [...] When \( \lambda \) is variable and large with high probability, the optimum rule approaches a simple asymptotic form, namely, stop as soon as \( k \), the observed number of bugs, satisfies \( k \leq f'(t)G(t)/cG'(t) \) [...] Further, the number of bugs remaining has a Poisson limiting distribution with mean \( f'(t)(1 - G(t))/cG'(t) \).
Dalal and Mallows stop a monotone discovery process: the cumulative count of bugs found in a module under test. Their approach differs from the fixed-width rules of Chow and Robbins (1965) and Glynn and Whitt (1992). Those rules stop when an estimate is precise enough. This rule stops when one more unit of testing is expected to find less than it costs. The authors chose it because the quantity a precision rule would need, the total number of bugs, cannot be estimated well.
The model¶
Let \( N \) be the unknown total number of bugs and \( K(t) \) the number found by test time \( t \).
- \( N \) is Poisson with mean \( \lambda \).
- \( \lambda \) varies across modules with a gamma distribution \( \Gamma(\alpha, \beta) \), with \( \alpha \) and \( \beta \) known.
- The time to find each bug is independent, with a known distribution \( G \) and density \( g \).
The cost of testing to time \( t \) is a known increasing function \( f(t) \). A bug costs \( a \) to fix during testing and \( b \) after release, and \( c = b - a \). The reward for stopping at \( t \) is
Under these assumptions \( K(t) \) is a sufficient statistic, and given \( \lambda \) it is a nonhomogeneous Poisson process with increments \( \lambda g(t) \) (Lemma 3.1).
The rules¶
Exact. A dynamic programming argument gives thresholds \( t_0 \leq t_1 \leq \cdots \): with \( k \) bugs found, testing continues while the expected additional reward \( V(k, t) \) is positive and stops at \( t_k \) (Theorems 3.4 to 3.6). The optimal policy has this simple form when \( f[G^{-1}(1 - e^{-y})] \) is convex while finite (Theorem 3.3).
Asymptotic. When \( \lambda \) is large, the rule becomes: stop as soon as
and the number of bugs left is approximately Poisson with mean \( f'(t)(1 - G(t))/c\,g(t) \). For an exponential finding time, \( G(t) = 1 - e^{-\mu t} \), and linear cost, \( f(t) = f t \), the rule is to stop when \( (f/\mu c)(e^{\mu t} - 1) \geq k \), and the bugs left are Poisson with mean \( f/\mu c \) (4.6). This is Starr's (1974) rule from capture–recapture sampling.
The rule reads naturally as a comparison of rates. The expected rate of new finds at time \( t \), estimated from the count so far, is \( k\, g(t)/G(t) \). The rule stops when the value of that rate, \( c\, k\, g(t)/G(t) \), falls to the cost rate \( f'(t) \).
Assumptions of the rule, and its guard against an early stop¶
The tail cannot be estimated. The introduction says plainly that, from data like a cumulative bug curve, "estimation of the tail of a distribution with a reasonable degree of precision is not possible." The rule is built so that it does not need the total \( N \).
A guard against an early stop, again. "To preclude the possibility of stopping before the asymptotic solution takes over we require a minimal time on test, say \( r \)." This is the same device as the \( n^{-1} \) term of Chow and Robbins and the \( a(t) \) of Glynn and Whitt.
Independence is not needed for asymptotic optimality. Following a suggestion of Bickel, the authors show the rule is asymptotically pointwise optimal under the sole assumption that \( K_N(t)/N \) converges to a differentiable \( G(t) \) as \( N \to \infty \), with no independence of the finding times. Bickel conjectured that an unknown but smooth \( G \) can be handled by replacing \( g(t)/G(t) = \tfrac{d}{dt}\log G(t) \) with an estimate. The authors did not study that rule.
The time scale is free. Any monotone change of time, \( t^* = q(t) \), carries the model and the strategies with it. A suitable choice makes \( G \) uniform or exponential, or makes the cost linear.
The paper also treats several classes of bugs, each with its own finding-time distribution, which gives an additive rule over the classes (Section 6). Its worked example fits \( K(t) \) as Poisson with mean \( \lambda(1 - e^{-\mu t}) \) by maximum likelihood to a real testing record.
Use in Hifuku¶
A survey's niche count is a monotone discovery process of the same shape: \( K(t) \) is the number of niches filled after \( t \) variations, and each reachable niche has some depth at which a survey first fills it. This paper bears on how the coverage of a survey grows, and on how a survey is stopped, in four ways.
- A candidate form for the coverage curve. If the niches are found at independent depths with a common distribution \( G \), the expected coverage curve is \( N\, G(t) \). The exponential case, \( \lambda(1 - e^{-\mu t}) \), is a concrete conjecture to test against a survey's recorded coverage curve. Niches are not found independently, since a walk reaches a niche from its neighbors, so the independence assumption needs its own check. Bickel's result suggests that a law of large numbers for \( K_N(t)/N \) may be enough.
- A warning about predicted end points. A rule that stops a survey once it can predict the depth at which the survey would converge needs an estimate of a tail, which is the quantity this paper says cannot be estimated precisely from a discovery curve. A rule stated in rates may be better determined than a rule stated as a predicted end point.
- The halt rule is already a rate rule. Hifuku's default halt fires when the growth exponent of the QD-score, the gain from a doubling of effort, falls to a threshold; the optional rate rule fires when the windowed coverage and precision rates fall below fixed thresholds. In the terms of this paper, both are marginal-rate stopping rules, with the threshold in place of the cost ratio \( f'/c \) (see the theory overview, Section 6).
- The guard appears a third time. Every stopping rule in this literature needs a minimum run before it may stop. Hifuku's halt judges no checkpoint before four times the variations of the first, two doublings of effort.