@test_warn, @test_nowarn, and @test_nothrow



Is there a way to test for warning throws? Like @test_throws does for exceptions.

Additionally, I would like tests that pass if a given code does not throw a Warning or an Exception. That is, I would also like a @test_does_not_throw (for exceptions) and a @test_does_not_warn (for warnings). How can I do these things?


On 0.6 there is a @test_warn and a @test_nowarn. PR that implemented it at: https://github.com/JuliaLang/julia/pull/19903


@kristoffer.carlsson Is there a @test_nothrow?


That is basically @test


It’s closer to @test_nowarn

Ref https://github.com/JuliaLang/julia/pull/19994#issuecomment-272322407
Ref https://github.com/JuliaLang/julia/issues/18780


I don’t understand that. @test fails if a condition is false. That is not the same as failing if an exception is not thrown.