MsTest 中的多个 ExpectedException
Multiple ExpectedException in MsTest
如何在 MSTest 中放置多个 ExpectedExceptionin
?
像这样
[ExpectedException(typeof(ArgumentException))]
[ExpectedException(typeof(NullReferenceException))]
因为它显示我 ExpectedException
双重错误
抱歉,您不能回答这个问题。
如果您查看 ExpectedExceptionAttribute Class 的文档,您会发现该属性并不意味着要在一个方法上多次使用。
This attribute can be specified on a method. There can be only one instance of this attribute on a method.
回答后续问题
Should I run test on each exception separately?
是的。具有不同期望的单独测试。你在控制测试,应该相应地安排它们。
如何在 MSTest 中放置多个 ExpectedExceptionin
?
像这样
[ExpectedException(typeof(ArgumentException))]
[ExpectedException(typeof(NullReferenceException))]
因为它显示我 ExpectedException
双重错误
抱歉,您不能回答这个问题。
如果您查看 ExpectedExceptionAttribute Class 的文档,您会发现该属性并不意味着要在一个方法上多次使用。
This attribute can be specified on a method. There can be only one instance of this attribute on a method.
回答后续问题
Should I run test on each exception separately?
是的。具有不同期望的单独测试。你在控制测试,应该相应地安排它们。