4 ms·
For my algorithmic code, the unit tests do the random input selection. Actually, it's often a sort of guided random testing. For example, if the algorithm has
by dmlorenzetti 14y ago
For my algorithmic code, the unit tests do the random input selection.
Actually, it's often a sort of guided random testing. For example, if the algorithm has a straightforward linear regime with an exact solution, and a nonlinear regime that has to be solved iteratively, the unit test will target, say, 2% of inputs at the linear regime, 1% at the breakpoint, and the rest at the nonlinear regime.
Mockups and stubs are another matter. My algorithmic code is numerical, so stubs are rarely an issue. If an algorithm needs, say, a matrix solver, you pretty much just have to use a real (unit-tested) matrix solver in there.