Search Results for

    Show / Hide Table of Contents

    Assert.Catch

    Assert.Catch is similar to Assert.Throws but will pass for an exception that is derived from the one specified.

    Exception Assert.Catch(TestDelegate code);
    Exception Assert.Catch(TestDelegate code,
                           string message, params object[] params);
    
    Exception Assert.Catch(Type expectedExceptionType, TestDelegate code);
    Exception Assert.Catch(Type expectedExceptionType, TestDelegate code,
                           string message, params object[] params);
    
    T Assert.Catch<T>(TestDelegate code);
    T Assert.Catch<T>(TestDelegate code,
                      string message, params object[] params);
    

    See Also

    • Assert.CatchAsync
    • Assert.Throws
    • 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