Is there a way to get more verbose output from @test
failures? Take this minimal example:
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:
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
<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:
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)? I’m using TestItemRunner.jl if that helps.