How can I put multiple ExpectedExceptionin
in a MSTest?
something like this
[ExpectedException(typeof(ArgumentException))]
[ExpectedException(typeof(NullReferenceException))]
because it shows me ExpectedException
in double error
If you look at the documentation for ExpectedExceptionAttribute Class you would see that the attribute is not meant to be used multiple times on a method.
This attribute can be specified on a method. There can be only one instance of this attribute on a method.
To answer the follow up question
Should I run test on each exception separately?
Yes. Separate tests with separate expectations. You are in control of the test and should arrange them accordingly.
Sorry, you can't is the simple answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.