Use NUnit Assert.Throws method or ExpectedException attribute?

后端 未结 5 1261
温柔的废话
温柔的废话 2020-12-04 13:57

I have discovered that these seem to be the two main ways of testing for exceptions:

Assert.Throws(()=>MethodThatThrows());

[ExpectedExc         


        
5条回答
  •  悲哀的现实
    2020-12-04 14:22

    You may also strong type the error you're expecting (like the old attrib version).

    Assert.Throws(() => breakingAction())
    

提交回复
热议问题