Print debug info for failed test

Just realized that I never got back here after the issue above was resolved, so in case anyone finds this vintage discussion: the pattern

@testset "my random 😉 tests" begin
    for i in 0:3
        debug = false
        debug |= !(@test(f(i)) isa Test.Pass)
        debug |= !(@test(g(i)) isa Test.Pass)
        if debug
            @info "test did not pass, printing debug info" i
        end
    end
end

works nicely for me for the purposes mentioned above.

(edit: !=== was too strict, corrected to !isa)

2 Likes