Search Results for

    Show / Hide Table of Contents

    Assert.DoesNotThrowAsync

    Assert.DoesNotThrowAsync verifies that the delegate provided as an argument does not throw an exception. See Assert.DoesNotThrow for synchronous code.

    Task Assert.DoesNotThrowAsync(Func<Task> asyncCode);
    Task Assert.DoesNotThrowAsync(Func<Task> asyncCode,
                                  string message, params object[] params);
    

    NUnit 4 and earlier

    In NUnit 4 and earlier this assertion would not need to be awaited and would return void instead of Task. The callback to invoke would also be passed as an AsyncTestDelegate instead of a Func<Task>. These behaviors were both changed in NUnit 5 to better align the API with modern .NET standards and conventions.

    void Assert.DoesNotThrowAsync(AsyncTestDelegate code);
    void Assert.DoesNotThrowAsync(AsyncTestDelegate code,
                                  string message, params object[] params);
    

    See Also

    • Assert.ThrowsAsync
    • ThrowsConstraint
    • Edit this page
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0