Currently Test.@testset
requires a begin/end
statement. This can be confusing since in actuality it needs to introduce a new scope block (due to emitting inside a try/catch). It would be a better semantic match for this to require using let
instead.
julia> @testset "embedding example" let
x = 1
end
ERROR: Expected begin/end block or for loop as argument to @testset
What about try
?
What about try?
Does try/end
behave identically to let/end
? I believe I would still prefer let/end
, as (in my opinion) it makes most sense to use try
only in places with catch
and/or finally
blocks.
It should be try since one testset failing should not stop the following ones from running.
The @testset
macro already puts a try-catch in the code that it generates, so maybe we should find a way to append the normal test handling code around the user's try
. Should we add it to the user's code, or error, if a user wants to do something in their own catch
or finally
after a @testset try
?
I'm recommending it should require use of exactly try/end
to "let the user see" that the testset macro is going to wrap it thusly.
Why would I care how the test macro is implemented internally? I haven't sern much confusion arising from this.
Most helpful comment
Why would I care how the test macro is implemented internally? I haven't sern much confusion arising from this.