Table of Contents
- Introduction
- What Are Unit Tests?
- The NUnit Testing Framwork
- TestFixture Attribute
- Test Attribute
- SetUp & Teardown Attributes
- ExpectedException Attribute
- Ignore Attribute
- The NUnit Assertion Class
- Running Your Tests
- Doing Test-Driven Development
- Using Mock Objects – DotNetMock
- Testing the Business Layer
- Testing the User Interface
- Conclusion
- More Info on the Web
Introduction
Although developers have been unit testing their code for years, it was typically performed after the code was designed and written. As a great number of developers can attest, writing tests after the fact is difficult to do and often gets omitted when time runs out. Test-driven development (TDD) attempts to resolve this problem and produce higher quality, well-tested code by putting the cart before the horse and writing the tests before we write the code. One of the core practices of Extreme Programming (XP), TDD is acquiring a strong following in the Java community, but very little has been written about doing it in .NET.