I am doing some testing for a package and I would like to have a string attached to the test result. Right now, I have to use @testset with a begin keyword.
If the goal is to print the label and a pass/fail, then maybe this’ll do the trick:
function print_test(label, cond)
printstyled("$label: ", color=:normal)
if cond
printstyled("PASS", color=:green)
else
printstyled("FAIL", color=:red)
end
print("\n")
end
and an example usage would look like:
print_test("Testing dummy equality", 1==0)
However, since this doesn’t use @test, there won’t be any useful error messages if the test fails and it won’t be counted within a testset block.
A possible workaround is to return true/false from the print_test() function, then it can be called by @test print_test(...). That’ll make the test count, but any error messages will still be useless probably.