A Julia package to generate parameters for unit tests and test data for unit tests. You tell it possible values for each parameter of a function, and it selects combinations of parameters that are most likely to find problems in that function.

  • All-pairs, all-triples, and higher-order coverage of test cases.
  • Combinatorial excursions from a base test case.
  • Convenient ways to avoid uninteresting parameter combinations, add necessary test cases, and increase coverage for subsets of parameters.


pkg> add https://github.com/adolgert/UnitTestDesign.jl


Write a unit test using the all_pairs function.

test_set = all_pairs(
    [1, 2, 3], ["low", "mid" ,"high"], [1.0, 3.7, 4.9], [:greedy, :relax, :optim]
for test_case in test_set
    test_result = function_under_test(test_case...)
    @test test_result == known_result(test_case)

This package doesn't help write the code that knows what the correct test result should be.

In order to test every possible input to the function above, you would need 81 tests, but this generates 10 tests that are more likely to find most faults because they include every combination of each pair of parameter values.

julia> using UnitTestDesign

julia> test_cases = all_pairs(
           [1, 2, 3], ["low", "mid" ,"high"], [1.0, 3.7, 4.9], [:greedy, :relax, :optim])
10-element Array{Array{Any,1},1}:
 [1, "low", 1.0, :greedy]
 [1, "mid", 3.7, :relax]
 [1, "high", 4.9, :optim]
 [2, "low", 3.7, :optim]
 [2, "mid", 1.0, :greedy]
 [2, "high", 1.0, :relax]
 [3, "low", 4.9, :relax]
 [3, "mid", 1.0, :optim]
 [3, "high", 3.7, :greedy]
 [2, "mid", 4.9, :greedy]