Unit testing in .NET
Every developer want clean code that works. So how does one get to maintainable and working code? And
moreover: keep it working.
- What every developer wants: Quality code that works; and keeps on working
- Finding bugs: not just in code. - Or how NASA lost a 125.000.000$ Mars orbiter
- What is unit testing? And what is a good unit test?
- Understanding the difference between a unit test and an integration test
- Test Driven Development - Should you be doing it?
- Role-playing: Marge, Homer and Bart
- The Triple-A of unit testing - and what has cooking to do with this?
Unit testing with Visual Studio with MSTest and XUnit
When Unit Testing, you will have to decide on frameworks. There are several ones out there, but which one do you need?
Visual Studio comes with a built in framework called MSTest, but you also have others, like the popular XUnit.
In this module, we will discuss pros and cons of these frameworks, and go into some best practices.
How do I know if I have tested enough? With code coverage you can see which paths in your code you have tested,
and easily discover untested conditional logic.
- MSUnit - Built-in into Visual Studio
- Building and running Unit Tests with MSUnit
- Using the Test Explorer Window
- Using Test Settings
- Live unit testing with Visual Studio
- Unit Testing best practices with XUnit
- Facts and Theories
- Unit testing parallelism
- Measuring and improving Code Coverage
- And what about Performance Testing?
- LAB: Implementing a library with testing
Writing testable code
If you want your code to be testable, you have to engineer your code for testing. You will learn about Stubs and
Mocks, and how to replace dependencies that might interfere with testing.
- Testing dependencies - and the art of writing testable code
- The difference between a Stub and a Mock
- How to replace dependencies with stub and mock objects
- The Extract and Override pattern
- How the MVVM pattern facilitates UI testing
- Replacing configuration in tests
Isolation Frameworks: MOQ
Building Stubs and Mocks can be a lot of work without an Isolation Framework. MOQ is an isolation framework that
allows you to easily build the Fake objects you need for building great
- Understanding Isolation Frameworks
- Building Stubs and Mocks with MOQ
- Checking arguments and return values
- Using Linq to Mocks
- LAB: Using MOQ
Writing solid, maintainable code that works. This is what every developer wants. This course guides you into the art of unit testing. You will learn how to build testable code. You will become familiar with various techniques and frameworks to give your code a good spin. At the end of this course you will go home with a solid and practical understanding of unit testing and how to apply this in real life. U2U is known for its real-life approach to training, so each chapter is accompanied with lots of hands-on labs.
This course is intended for experienced C# developers.