# Customize test failure display

**URL:** https://discourse.julialang.org/t/customize-test-failure-display/120610
**Category:** General Usage
**Created:** [September 29, 2024, 3:35am UTC](https://discourse.julialang.org/t/customize-test-failure-display/120610 "2024-09-29T03:35:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [September 29, 2024, 3:35am UTC](https://discourse.julialang.org/t/customize-test-failure-display/120610/1 "2024-09-29T03:35:05Z")

</div>

I like how it shows the values of `y` and `x` here

```julia
julia> @test y < x
Test Failed at REPL[6]:1
  Expression: y < x
   Evaluated: 2 < 1

```

Can I make it do that for the arguments of my custom function too?

```julia
julia> eq(x,y) = x == y;

julia> @test eq(x,y)
Test Failed at REPL[5]:1
  Expression: eq(x, y)

```

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [September 29, 2024, 6:10am UTC](https://discourse.julialang.org/t/customize-test-failure-display/120610/2 "2024-09-29T06:10:17Z")

</div>

There are a few options listed here:

> [@Define test error message programmatically](https://discourse.julialang.org/t/define-test-error-message-programmatically/116142):
>
> Is there a way for a test to display a custom error message, without giving up on the nice display of numerical values equality / comparison tests? The workaround in [Custom error message from @test macro](https://discourse.julialang.org/t/custom-error-message-from-test-macro/2299) is only a partial solution for this: julia\> using Test julia\> x, y = 1, 2; julia\> msg = "The test failed for this reason: ..."; julia\> @test x == y # numerical values, no message displayed Test Failed at REPL[16]:1 Expression: x == y Evaluated: 1 == 2 ERROR: There was an error during…

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [September 29, 2024, 6:22am UTC](https://discourse.julialang.org/t/customize-test-failure-display/120610/3 "2024-09-29T06:22:35Z")

</div>

> <https://github.com/JuliaLang/julia/issues/55925>
>
> I like how it shows the values of \`y\` and \`x\` here
> 
> 
> \`\`\`
> julia\> @test y \< x
> …
> Test Failed at REPL\[6\]:1
> Expression: y \< x
> Evaluated: 2 \< 1
> \`\`\`
> 
> Can I make it do that for the arguments of my custom function too?
> 
> \`\`\`
> julia\> eq(x,y) = x == y;
> 
> julia\> @test eq(x,y)
> Test Failed at REPL\[5\]:1
> Expression: eq(x, y)
> \`\`\`
> 
> A few options are presented \[on Discourse\](https://discourse.julialang.org/t/define-test-error-message-programmatically/116142) but they all require intervention by the tester at the test site.
> 
> I want to customize the error display by dispatching on the predicate function and/or its arguments. So for my custom \`eq\` and maybe its argument types I could get
> 
> \`\`\`jl
> julia\> @test eq(x,y)
> Test Failed at REPL\[5\]:1
> Expression eq(x,y)
> Evaluated eq(1,2)
> \`\`\`
> 
> and for other predicates I could get other displays.
