Nunit async test exception assertion

后端 未结 6 1682
感情败类
感情败类 2020-12-29 18:37

[Edit (May 2020)] - This issue has been reportedly addressed in newer releases of NUnit. Please see Nunit.ThrowsAsync. (Ref this answer, thanks @James-Ross)

6条回答
  •  感情败类
    2020-12-29 19:28

    This is an example from documentation:

    var ex = Assert.ThrowsAsync(async () => await MethodThatThrows());
    
    1. Use ThrowsAsync
    2. Use async / await

    https://docs.nunit.org/articles/nunit/writing-tests/assertions/classic-assertions/Assert.ThrowsAsync.html

提交回复
热议问题