reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anupam <anupam...@gmail.com>
Subject Re: xUnit error messages?
Date Tue, 19 Jan 2016 23:26:46 GMT
Take a look at this: https://github.com/xunit/xunit/issues/350 ; Nice
discussion on why xUnit did not add the string message.
Quoting from the link:
"*We obsolesced most of the Assert methods which take user messages.* The
only ones we left are those on Assert.True and Assert.False, which tend to
be catch-all asserts which might require documentation. We will be removing
the obsolesced methods in 1.0 RTM, so please move your calls to the
message-less variants.

I could not find a blog post that talked about "why", even though we've
mentioned it several times. I'm just not sure it every got a permalink.

We are a believer in self-documenting code; that includes your assertions.
If you cannot read the assertion and understand what you're asserting and
why, then the code needs to be made clearer. Assertions with messages are
like giving up on clear code in favor of comments, and with all the
requisite danger: if you change the assert but not the message, then it
leads you astray.

To support people writing better assertions, v2 includes a NuGet package
that ships the assertion library in source code. The Assert class is a
partial, so you can add whatever assertions you like to the built-in set.
We've even gone so far as to publish gists with extra assertions, just to
show people how it's done:https://gist.github.com/bradwilson/7797444"


Personally I do not like using Assert.True instead of Assert.Equal.
We should instead create our own assertion for equals with message?

I don't feel strongly about this though. After so many +1s, I guess people
have already made a decision, just putting my point out there.


On 19 January 2016 at 14:02, Byung-Gon Chun <bgchun@gmail.com> wrote:

> +1
>
> -Gon
>
> 2016. 1. 20. 오전 6:13 Dongjoon Hyun <dongjoon@apache.org> 작성:
>
> > +1.
> >
> > Dongjoon
> >
> >> On Tue, Jan 19, 2016 at 1:01 PM, Andrew Chung <afchung90@gmail.com>
> wrote:
> >>
> >> I am +1 for it.
> >>
> >> Thanks,
> >> Andrew
> >>
> >>> On Tue, Jan 19, 2016 at 11:21 AM, Markus Weimer <markus@weimo.de>
> wrote:
> >>>
> >>>> On 2016-01-19 11:17, Mariia Mykhailova wrote:
> >>>> Some xUnit methods take error message, for example, Assert.True
> >>>> Maybe we should use that instead of Assert.Equal when we want specific
> >>> message.
> >>>
> >>> Ah, that sounds good. What do others think: Should we make this part of
> >>> our coding style?
> >>>
> >>> Markus
> >>
>



-- 
Anupam
Bellevue, WA
Ph: +1 (425)-777-5570

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message