diff --git a/xUnitStudy.WebApi.Test/UseXUnitTest.cs b/xUnitStudy.WebApi.Test/UseXUnitTest.cs index 6a15c82..8fd98b5 100644 --- a/xUnitStudy.WebApi.Test/UseXUnitTest.cs +++ b/xUnitStudy.WebApi.Test/UseXUnitTest.cs @@ -113,5 +113,22 @@ namespace xUnitStudy.WebApi.Test Assert.True(true,"使用Theory特性和InlineData特性,传递不同参数,多次执行测试"); } + + /// + /// 断言不抛出异常 + /// + [Fact] + public void Assert_NoThrow_Test() + { + Action noThrowAction =() => + { + //业务代码 + Task.Delay(10); + //throw new Exception("测试异常"); + }; + + var exception = Record.Exception(noThrowAction); + Assert.Null(exception); + } } }