AssertEx - a set of simple assert extensions to give you more choices and easier to read tests.
PowerShell C#


AssertEx is a simple library of helper methods for unit testing. Originally created for use with MS-Test, it is framework neutral so should be usable with any .NET unit testing framework.



The static class that contains the helper methods

Standard Exception Helpers

  • AssertEx.DoesNotThrow(delegate testCode)
  • AssertEx.Throws(Type type, delegate testCode)
  • AssertEx.Throws<T>(delegate testCode)

Task-Async Exception Helpers

  • AssertEx.TaskDoesNotThrow(delegate testCode)
  • AssertEx.TaskDoesNotThrow<T>(delegate testCode)
  • AssertEx.TaskThrows(Type type, delegate testCode)
  • AssertEx.TaskThrows<T>(delegate testCode)


An exception class that is used by AssertEx when an assertion fails. Nothing fancy here.


Many thanks to Jim Newkirk and Brad Wilson for the whole Assert.Throws() thing in, from which this work is obviously and blatantly derived. And to shiftkey for the Task-Async versions.