# Breaking up long testset descriptions

**URL:** <https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488>\
**Category:** General Usage\
**Tags:** testing\
**Created:** [February 15, 2022, 3:28pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488 "2022-02-15T15:28:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielsoutar](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@danielsoutar](https://discourse.julialang.org/u/danielsoutar)\
**Post date:** [February 15, 2022, 3:28pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488/1 "2022-02-15T15:28:26Z")

</div>

Very simple question - maybe even a feature request to open on JuliaLang repo.

Basically, I would like to enforce a style guide where my code is at most 80 characters long, including tests. However, the `@testset` macro does not allow breaking up description strings across multiple lines. I have in mind something like the following:

```julia
using Test

@testset "One very verbose and some would say" *
         "needlessly verbose testset description" begin
    @test true
    # ...
end

```

Trying this in the REPL with Julia 1.6.0 on an Intel-based Linux machine (Ubuntu 20.04, Focal Fossa) gets this error:

```julia
ERROR: LoadError: Unexpected argument "One very verbose and some would say" * "needlessly verbose testset description" to @testset
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] parse_testset_args(args::Tuple{Expr})
   @ Test /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1280
 [3] testset_beginend(args::Tuple{Expr, Expr}, tests::Expr, source::LineNumberNode)
   @ Test /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1123
 [4] var"@testset"( __source__ ::LineNumberNode, __module__ ::Module, args::Vararg{Any, N} where N)
   @ Test /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1115
in expression starting at REPL[3]:1

```

If you have sufficiently nested testsets, or would rather have testsets flattened and have longer naming to compensate (e.g. if you wanted to use something like `ReTest.jl`), then this is a bit annoying from a style perspective.

Is there any _ **native** _ Julia solution? I am guessing that another macro can be used for the above, but it seems like a sensible enough request for the testset macro to support multi-line strings by default. It is just a single string after all - you’re not even changing the argument signature of the macro.

Thanks in advance for any advice and/or assistance.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 15, 2022, 3:35pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488/2 "2022-02-15T15:35:46Z")

</div>

```julia

julia> @testset "One very verbose and some would say \
                needlessly verbose testset description" begin
           @test true
           # ...
       end

julia> a = "One very verbose and some would say" *
                       "needlessly verbose testset description"

julia> @testset "$a" begin
           @test true
           # ...
       end

```

---

<div class="post-metadata">

**Author:** ![danielsoutar](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@danielsoutar](https://discourse.julialang.org/u/danielsoutar)\
**Post date:** [February 15, 2022, 3:40pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488/3 "2022-02-15T15:40:33Z")

</div>

Thanks for the quick reply! The second approach works, the first fails with an error about an invalid escape sequence though:

```julia
julia> @testset "One very verbose and some would say \
                       needlessly verbose testset description" begin
ERROR: syntax: invalid escape sequence
Stacktrace:
 [1] top-level scope
   @ none:1

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 15, 2022, 3:42pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488/4 "2022-02-15T15:42:08Z")

</div>

update your Julia to 1.7 (if you can)

---

<div class="post-metadata">

**Author:** ![danielsoutar](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@danielsoutar](https://discourse.julialang.org/u/danielsoutar)\
**Post date:** [February 15, 2022, 3:42pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488/5 "2022-02-15T15:42:42Z")

</div>

That’s a nice reason to upgrade. Thanks a lot @jling!

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [February 15, 2022, 4:28pm UTC](https://discourse.julialang.org/t/breaking-up-long-testset-descriptions/76488/6 "2022-02-15T16:28:47Z")

</div>

Triple-quoted multi-line literals work too, as well as expression interpolations like this:

```julia
@testset "$(
    "A long " *
    "description " *
    "spanning " *
    "many " *
    "lines")" begin
       @test true
end

```
