I want to make a new testset type such that doing
@testset MyTest "integer addition" begin
@test 1 + 1 == 2
inserts the statement
println("- "^40) both before and after printing the results of the
@test (those cool Test summaries).
How do I do it? The documentation on Unit testing is a bit sparse around this point. It says is that it is possible to define a custom test set, subtype of
EDIT: In addition to the above, would be nice to have a way to do
t = time() at the start of the test and
elapsed = time() - t at the end, to print time taken. I also have no clue how to do this (using custom testsets of course).
Apparently I missed that this page exists: Unit Testing · The Julia Language !
I will use it to try and answer my own question!
I got no idea how could this be done with a custom
testset, as the interface is extremely complicated for my taste. I don’t even know if what I want to do is possible.
My solution is my own custom function:
custom_testset(description, f, args...)
Wrap a testset around `f(args...)` which times the result
and separates the test from others (`println`).
function custom_testset(description, f, args...)
t = time()
@testset "$(d)" begin
println("Required time: $(round(time()-t, digits=3)) sec.")