# \`@test\_throws ArgumentError throw(ArgumentError)\` fails

**URL:** https://discourse.julialang.org/t/test-throws-argumenterror-throw-argumenterror-fails/89779
**Category:** General Usage
**Tags:** testing
**Created:** [November 4, 2022, 2:31pm UTC](https://discourse.julialang.org/t/test-throws-argumenterror-throw-argumenterror-fails/89779 "2022-11-04T14:31:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)
#### Post date: [November 4, 2022, 2:31pm UTC](https://discourse.julialang.org/t/test-throws-argumenterror-throw-argumenterror-fails/89779/1 "2022-11-04T14:31:45Z")

</div>

I seem to be missing something obvious here—why does the following test fail in v1.8.2?

```julia
julia> using Test

julia> @test_throws ArgumentError throw(ArgumentError)
Test Failed at REPL[3]:1
  Expression: throw(ArgumentError)
    Expected: ArgumentError
      Thrown: DataType
ERROR: There was an error during testing

julia> throw(ArgumentError)
ERROR: ArgumentError
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

```

---

<div class="post-metadata">

### Author: ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)
#### Post date: [November 4, 2022, 2:57pm UTC](https://discourse.julialang.org/t/test-throws-argumenterror-throw-argumenterror-fails/89779/2 "2022-11-04T14:57:20Z")

</div>

You need to instantiate `ArgumentError` for this to work:

```julia
julia> @test_throws ArgumentError throw(ArgumentError("hi"))
Test Passed
      Thrown: ArgumentError

```
