# Different test results of @test\_opt inside and outside the @testitem block

**URL:** https://discourse.julialang.org/t/different-test-results-of-test-opt-inside-and-outside-the-testitem-block/119564
**Category:** VS Code
**Tags:** testing, jet
**Created:** [September 18, 2024, 4:45pm UTC](https://discourse.julialang.org/t/different-test-results-of-test-opt-inside-and-outside-the-testitem-block/119564 "2024-09-18T16:45:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![aaoo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaoo/32/209309_2.png) [@aaoo](https://discourse.julialang.org/u/aaoo)
#### Post date: [September 18, 2024, 4:45pm UTC](https://discourse.julialang.org/t/different-test-results-of-test-opt-inside-and-outside-the-testitem-block/119564/1 "2024-09-18T16:45:58Z")

</div>

I found that when the function contains `@warn`, the testing results of `@test_opt` inside the `@testitem` block differ from those outside, i.e. in the REPL. Please see the code below.

Could someone explain why this happens and how to resolve this difference? Thanks for your time.

```julia
## put following codes to package module file
function wuyu(x)
     x > 1 && @warn "this is a warning."
     return x
end
@testitem "jet test opt" begin
    using JET
    @test_opt wuyu(2) # Test fail
end
# run following codes directly in the REPL
using JET
@test_opt wuyu(2) # Test pass

```
