# Automatically drop into debugger or infiltrate on test error or failure

**URL:** https://discourse.julialang.org/t/automatically-drop-into-debugger-or-infiltrate-on-test-error-or-failure/98423
**Category:** New to Julia
**Created:** [May 6, 2023, 10:33pm UTC](https://discourse.julialang.org/t/automatically-drop-into-debugger-or-infiltrate-on-test-error-or-failure/98423 "2023-05-06T22:33:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jwkvam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwkvam/32/30461_2.png) [@jwkvam](https://discourse.julialang.org/u/jwkvam)
#### Post date: [May 6, 2023, 10:33pm UTC](https://discourse.julialang.org/t/automatically-drop-into-debugger-or-infiltrate-on-test-error-or-failure/98423/1 "2023-05-06T22:33:41Z")

</div>

tl;dr: I’m looking for roughly the equivalent of `pytest --pdb` for those familiar with pytest.

I would like to drop into a debugger or infiltrator when a unit test fails. If I run a test and it fails and I can’t immediately figure it out, I rerun the test with `@infiltrate` sprinkled in. I feel like it would greatly improve my workflow if I could just have that as an option when I run my unit tests. Then I wouldn’t need to add and remove `@infiltrate`.

I was trying to wrap the `@test` macro, such that if it returned a fail or error result, it would run `@infiltrate`. I haven’t been clever enough to figure out how to do that however.

Edit: After some more thinking, this seems to work for me so far.

```julia
using Test
using Infiltrator

macro itest(ex, kws...)
    quote
        o = @test($(esc(ex)), $(esc.(kws)...))
        typeof(o) != Test.Pass && @infiltrate
        o
    end
end

```

Then I can just use `@itest` instead of `@test`.

---

<div class="post-metadata">

### Author: ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)
#### Post date: [May 7, 2023, 12:44pm UTC](https://discourse.julialang.org/t/automatically-drop-into-debugger-or-infiltrate-on-test-error-or-failure/98423/2 "2023-05-07T12:44:46Z")

</div>

If something like this could be done outside of unit testing, that would be useful as well.

The use case would be, for example, a long running simulation with edge cases that I may not have anticipated. When the simulation fails, not having to rerun it after inserting `@infiltrate` would be a time saver.

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [May 7, 2023, 1:03pm UTC](https://discourse.julialang.org/t/automatically-drop-into-debugger-or-infiltrate-on-test-error-or-failure/98423/3 "2023-05-07T13:03:22Z")

</div>

That’s what Rebugger.jl did. But it’s not currently maintained due to lack of humanpower. I’m happy to accept PRs to get it back in working order.
