Improving NUnit custom constraints with syntax helpers

NUnit’s custom constraints support is a powerful feature for improving the quality and clarity of tests involving objects with complex state, yet – by themselves – the syntax is messy and difficult to read. However, a simple trick of using static methods can greatly enhance the readability of these constraints. Continue reading “Improving NUnit custom constraints with syntax helpers”

Using custom constraints to improve NUnit test quality, part 2 of 2

Writing good quality unit tests for your code can be hard. Neither multiple asserts in one test, nor multiple single-assert tests are ideal solutions. There are alternatives though, which this article explores. It culminates in a description of a powerful way of writing tests using NUnit.
Continue reading “Using custom constraints to improve NUnit test quality, part 2 of 2”

Using custom constraints to improve NUnit test quality, part 1 of 2

Writing unit tests for your code is a laudable thing to do. Most developers who have tried using a test-orientated approach to development will agree that it is a superior approach to development, compared with not writing them. However, writing good tests can be hard. This two-part article explores the arguments for multiple asserts verses multiple single-assert tests and – having explained why neither is ideal – examines a powerful alternative that solves the problems with both approaches.
Continue reading “Using custom constraints to improve NUnit test quality, part 1 of 2”