In this video, the different kinds of testing are presented and where TDD fits in. Student is provided plenty of examples or various test methods along with a definition of what unit testing is and how Test Driven Development relates to it. Advantages of Test Drivent Development are given wich inclulded but not limited to clear intentions, decoupling, and YAGNI.
- In software development, there's a lot of different approaches to testing an application. For example, there's acceptance testing, black box testing, compatibility testing, conformance, functional, integration, load, regression, smoke, system, unit, white box testing. Explaining all of them is beyond the scope of this course, but it's important to note most companies don't apply all these. They'll just apply a few. And one of the most popular is unit testing which plays an important role in test-driven development.
Unit testing is the process in which tiny testable parts of a program, referred to as units, are independently tested for expected functionality. It could be either automated or manually done. Test-driven development is a process that uses these unit tests to drive to drive the design of software. It provides several advantages, such as, your intentions are clear. You know what you want and then you create it. It encourages decoupling so that you don't have one method or class that depends on another.
When code is tightly coupled, if you update one method, it might break another. And then you're forced to update that one too. You don't want that. It's easier to catch bugs early on. You're forced to write test cases earlier rather than later, where you're likely to miss test cases. And lastly, it helps you achieve what some refer to as YAGNI. You ain't gonna need it. That is, writing test cases first prevents you from writing excess code you don't end up using later on. The process of executing test-driven development has a motto.
Red, green, refactor. That's up next.
In this course, Reynald Adolphe explains the principles of test-driven development and shows how to apply them to two different C# workflows. First, he creates a new test-driven project. He writes the test cases before the code to drive the design of the program. In the second scenario, he writes test cases for an existing C# project, to find bugs before it goes live. Along the way, Reynald uses Microsoft's MSTest, but he also introduces other testing tools (such as the unit testing framework xUnit and the mocking framework Moq) and theories (such as the red-green-refactor mantra and SOLID principles) that make test-driven development so efficient.
- Different approaches to testing
- Using testing tools and mocking frameworks
- Creating a simple C# test-driven project
- Adding a failing test
- Updating tests to pass
- Refactoring code
- Using Moq to test data