# Skipping a whole \`@testset\`?

**URL:** <https://discourse.julialang.org/t/skipping-a-whole-testset/65006>\
**Category:** General Usage\
**Tags:** testing\
**Created:** [July 20, 2021, 9:33pm UTC](https://discourse.julialang.org/t/skipping-a-whole-testset/65006 "2021-07-20T21:33:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [July 21, 2021, 7:21pm UTC](https://discourse.julialang.org/t/skipping-a-whole-testset/65006/4 "2021-07-21T19:21:26Z")

</div>

Thanks @Satvik, but I was aiming in particular at the case when some tests are ‘broken’, rather than wanting to switch between them interactively.

I spent a few hours learning that wrapping `@testset` in another macro isn’t possible (at least for someone with my limited knowledge of macros), see [Calling a macro from within a macro, revisited](https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680), [https://github.com/JuliaLang/julia/issues/37691](https://github.com/JuliaLang/julia/issues/37691), and [Nested macros and esc](https://discourse.julialang.org/t/nested-macros-and-esc/47857). After giving up on that, I ended up coming up with this macro that skips a testset and adds a `DefaultTestSet` with a dummy broken test so that it can show up in the summary:

```julia
import Test: Test, finish
using Test: DefaultTestSet, Broken
using Test: parse_testset_args

"""
Skip a testset

Use `@testset_skip` to replace `@testset` for some tests which should be skipped.

Usage
-----
Replace `@testset` with `@testset "reason"` where `"reason"` is a string saying why the
test should be skipped (which should come before the description string, if that is
present).
"""
macro testset_skip(args...)
    isempty(args) && error("No arguments to @testset_skip")
    length(args) < 2 && error("First argument to @testset_skip giving reason for "
                              * "skipping is required")

    skip_reason = args[1]

    desc, testsettype, options = parse_testset_args(args[2:end-1])

    ex = quote
        # record the reason for the skip in the description, and mark the tests as
        # broken, but don't run tests
        local ts = DefaultTestSet(string($desc, " - ", $skip_reason))
        push!(ts.results, Broken(:skipped, "skipped tests"))
        local ret = finish(ts)
        ret
    end

    return ex
end

```

I’d still vote for something like this as a feature of the standard-library `@testset` and `DefaultTestSet`.

---

_[View the full topic](https://discourse.julialang.org/t/skipping-a-whole-testset/65006)._
