BUT, one could easily imagine an extension to the unit testing framework where inner tests work, too. With a combination of coverage and unit testing, you can usually get these inner unit tests to run and record their status the same way outer ones do in module+. Pyret, for example, does exactly this, so we should be able to do it too.
(Pyret co-lead dev here.)
The way nested tests work for us in Pyret is actually simpler than that: As a dummy example, consider a curried addition function
fun make-adder(num1 :: Number):
fun result(num2 :: Number):
num1 + num2
where:
result(5) is num1 + 5
result(10) is num1 + 10
end
result
where:
make-adder(3)(6) is 9
make-adder(4)(2) is 6
end
This definition will
run six test cases — the two test cases for make-adder
will each run the two nested test cases for result.
These will be reported as three blocks of test cases: one block
for make-adder
and two blocks for result.
The test cases for result
run in the lexical scope of the body of make-adder,
so they have closed over num1
as part of their environment.
(In practice, this can lead to many, many test cases, obviously. So when running a program in Pyret, by default we only run the test cases lexically present in the main module of the program.)
~ben