关于[Testing Exceptions with xUnit and Actions]的摘要:
When you're writing unit tests for a method, it's a good idea to test various failure conditions ("sad paths") in addition to testing the expected, everything is working condition ("happy path"). In particular, if you have a method that may throw exceptions, especially if they're custom domain exceptions, you should be sure you're testing this behavior. Another common source of exceptions is guard clauses, which are used to keep your method clean while ensuring its inputs adhere to the method's expectations.
原文地址: https://ardalis.com/testing-exceptions-with-xunit-and-actions/