From the course: ASP.NET Core: Test-Driven Development

TDD and tools - ASP.NET Core Tutorial

From the course: ASP.NET Core: Test-Driven Development

Start my 1-month free trial

TDD and tools

- [Instructor] Let's talk about tools for test-driven development. In this class, I'll be using Visual Studio 2017 Community Edition. It's the most basic edition. So if you're using professional or enterprise, everything should still work the same way as in the demos. I'll also be using ReSharper. A commonly used Visual Studio extension. ReSharper is a productivity tool which I'll be using to perform refactorings and to run our tests. If you don't have ReSharper installed, your interface might look a little bit different. Occasionally, I'll try to call out alternatives if you're not using ReSharper. In most cases, it might mean you just have to do a little more typing. You can find out more about ReSharper in the documentation. We'll also be making use of a few libraries. We'll be using xUnit, which is a testing framework available for dotnet core. And we'll be using Moq which is a framework for creating test mocks. In the demo application, we'll be using a few C sharp design patterns to show how they work nicely with tester and development. I'll be making use of the service and repository design patterns. To give a quick overview, repositories are responsible for interfacing with the data store. The services are responsible for performing business logic and the MVC controllers are mostly responsible for presenting data to the user and taking input from the user. You can learn more about the repository pattern and other design patterns in the C sharp design patterns course, in the course library. As I mentioned in the introduction, I already expect you may have some familiarity with test driven development, but let's have a quick recap to go over some of the basics. At the core of test driven development, is the red green refactor cycle. You start at the red state, where you write a failing test. Then you move onto the green state, where you make a small change to make that test pass. And then you move onto the refactor state where you restructure your code and move it around to improve the quality of your code. And then you go back to the red state and continue the cycle until you finish testing your current method. There are many other components and rules to test driven development, but for the purposes of this course, we're just going to stick to the basics of how to apply TDD in ASP dot net core using C sharp. Let's talk about why you might want to do test driven development and some of the benefits. If you practice TDD, it can make you confident in the code that you're writing. It can also make you confident in the changes that you and your team are making, and it provides you with quick feedback for the code that you're writing. You'll hear me talk a lot about confidence during the demos. If you have confidence in your code and your tests, you can feel much more comfortable about the code that you're writing. And that helps make your changes faster and with less bugs.

Contents