Skip to content

Customize test failure display #55925

@jariji

Description

@jariji

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

I would like to make it do that for custom functions.

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 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

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

and other predicates could define other displays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsystemThe unit testing framework and Test stdlib

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions