Raathigesh
Raathigesh

Reputation: 2336

XUnit - Assert.DoesNotThrow with Particular Exception Type Only

Is it possible to use Assert.DoesNotThrow with a particular exception type?

For example how do I verify that a method call is not throwing NullReferenceExceptions specifically but it may throw NotSupportedException which I don't care about. ?

Upvotes: 2

Views: 4229

Answers (1)

cat916
cat916

Reputation: 1361

There's a pattern null checking in xUnit.

var ex = Record.Exception(...);
Assert.Null(ex);

It's bit late; however, hope it helps you :).

Upvotes: 8

Related Questions