Partager via


Assert.Throws

xUnit.net provides the Assert.Throws method for testing exceptions, instead of the ExpectedException attribute. In his original announcement, James Newkirk explains why this is a much better approach, and I can only agree.

However, those of us that for one reason or another use MSTest are currently stuck with the ExpectedException attribute, but I've entered a suggestion on Connect that we get a similar method in MSTest. If you would also like to have Assert.Throws in MSTest, go to the suggestion and vote for it!

Comments

  • Anonymous
    November 12, 2008
    Interesting. I did not know that MS employees themselves post suggestions via Connect - thought you guys have some inner channels for that. Ah well. I have in fact spotted this ticket earlier, and already validated/voted on it.

  • Anonymous
    November 12, 2008
    Last time I asked, DevDiv preferred that employees outside their org used Connect just like everyone else. I'm sure there are other channels as well, but I didn't pursue the matter :)

  • Anonymous
    November 17, 2008
    Why not just import the xUnit assembly and use its Assert classes? :) We do that even though we're using MSTest as the framework. For that matter, the 3.5 extensions are very handy as well.

  • Anonymous
    November 17, 2008
    The comment has been removed