# @test\_warn, @test\_nowarn, and @test\_nothrow

**URL:** https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700
**Category:** General Usage
**Tags:** testing
**Created:** [January 26, 2017, 1:06pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700 "2017-01-26T13:06:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)
#### Post date: [January 26, 2017, 1:06pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/1 "2017-01-26T13:06:56Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [January 26, 2017, 1:32pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/2 "2017-01-26T13:32:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)
#### Post date: [January 26, 2017, 2:16pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/3 "2017-01-26T14:16:03Z")

</div>

@kristoffer.carlsson Is there a `@test_nothrow`?

---

<div class="post-metadata">

### Author: ![PabloZubieta](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@PabloZubieta](https://discourse.julialang.org/u/PabloZubieta)
#### Post date: [January 26, 2017, 2:52pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/4 "2017-01-26T14:52:17Z")

</div>

That is basically `@test`

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [January 26, 2017, 3:17pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/5 "2017-01-26T15:17:00Z")

</div>

It’s closer to `@test_nowarn`

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

---

<div class="post-metadata">

### Author: ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)
#### Post date: [January 27, 2017, 10:47pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/6 "2017-01-27T22:47:41Z")

</div>

> [@PabloZubieta](#):
>
> That is basically @test

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.

---

<div class="post-metadata">

### Author: ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)
#### Post date: [January 27, 2017, 10:54pm UTC](https://discourse.julialang.org/t/test-warn-test-nowarn-and-test-nothrow/1700/7 "2017-01-27T22:54:20Z")

</div>

[https://github.com/JuliaLang/julia/issues/20284](https://github.com/JuliaLang/julia/issues/20284)
