How to implement XUnit descriptive Assert message?

后端 未结 2 1170
迷失自我
迷失自我 2021-02-05 01:45

Context

in XUnit github I found this: Add Assert.Equal(expected, actual, message) overload #350 (so a developer ask for a non existing overload see

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 02:05

    Use the suggestions provided at the link. Like fluent assertions or create your own assertion that wraps the Assert.True or Assert.False which were left with their message overloads. It was mentioned further down

    Quote

    You can provide messages to Assert.True and .False. If you simply cannot live without messages (and refuse to use a different assertion), you could always fall back to:

    Assert.True(number == 2, "This is my message");
    

    Quote:

    If you really want to have messages you could add Fluent Assertions or maybe xbehave to your test projects and use their syntax. Fluent Assertions even throws xunit.net exceptions if it encounters its presence.

提交回复
热议问题