# Verbose test output with highlighted differences

**URL:** https://discourse.julialang.org/t/verbose-test-output-with-highlighted-differences/128067
**Category:** New to Julia
**Tags:** testing
**Created:** [April 14, 2025, 3:54pm UTC](https://discourse.julialang.org/t/verbose-test-output-with-highlighted-differences/128067 "2025-04-14T15:54:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Peter\_Hill](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter_hill/32/216260_2.png) [@Peter\_Hill](https://discourse.julialang.org/u/Peter_Hill)
#### Post date: [April 14, 2025, 3:54pm UTC](https://discourse.julialang.org/t/verbose-test-output-with-highlighted-differences/128067/1 "2025-04-14T15:54:38Z")

</div>

Is there a way to get more verbose output from `@test` failures? Take this minimal example:

```julia
julia> expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
julia> result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 99, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
julia> @test expected == result

Test Failed at REPL[3]:1
  Expression: expected == result
   Evaluated: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]

```

The long vectors are truncated, but this unfortunately hides the element that’s different.

Compare to pytest in python:

```python
def test_foo():
  expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
  result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 99, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
  assert expected == result

```

```julia
<snip>
> assert expected == result
E assert [1, 2, 3, 4, 5, 6, ...] == [1, 2, 3, 4, 5, 6, ...]
E       
E At index 10 diff: 11 != 99
E Use -v to get more diff

```

Running `pytest -vv` also prints the full diff of the two arrays:

```julia
  Full diff:
    [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
  - 99,
  + 11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
    ]

```

Is there a way to get similar output with Test.jl, or another package (e.g. rust’s [pretty\_assertions](https://crates.io/crates/pretty_assertions))? I’m using TestItemRunner.jl if that helps.

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [April 14, 2025, 5:13pm UTC](https://discourse.julialang.org/t/verbose-test-output-with-highlighted-differences/128067/2 "2025-04-14T17:13:33Z")

</div>

There’s WhyNotEqual.jl:

```julia
julia> using WhyNotEqual

julia> whynot(==, expected, result)
DifferentAndNoChildren: When applying `lens` to both objects, we get `obj1` and `obj2`.
obj1 and obj2 are different, but they don't have any children.
lens: (@o _[11])
obj1: 11
obj2: 99

```

---

<div class="post-metadata">

### Author: ![adolgert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adolgert/32/20286_2.png) [@adolgert](https://discourse.julialang.org/u/adolgert)
#### Post date: [April 26, 2025, 8:07pm UTC](https://discourse.julialang.org/t/verbose-test-output-with-highlighted-differences/128067/3 "2025-04-26T20:07:38Z")

</div>

There are two packages that extend the @testset macro: TestSetExtensions.jl and TestTools.jl. Both of them use the DeepDiffs.jl package to make better reporting of failed tests.

And WhyNotEqual looks good too!
