Skip to content
0:00 / 0:00

#xunit#unittesting#c#

Intro to Unit Testing in C# using XUnit

IAmTimCorey

441K subscribers • 15 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • A classic. People kept recommending it from 2019 to 2023.
  • Presented by Tim Corey

Beginner. No background in the topic needed.

449K views8 years ago3 recommendations

Tools and practiceTestingC# and .NET

Tim Corey explains the fundamentals of unit testing in C# using the xUnit framework, covering best practices and testable code design.

Unit testing is an important part of writing quality software. It is also a controversial and somewhat difficult topic to get started in. In this video, we walk through why we would use unit testing, what a unit test is, how to create a test, and how to deal with some of the more difficult situations. Along the way, we will cover best practices, the pitfalls to avoid, and how to write more testable code. This video uses XUnit instead of NUnit or MSTest based upon my preference. However, the techniques taught will apply to other test types. Newsletter signup (with exclusive discounts): signup.iamtimcorey.com/ (your email will be kept safe and you will not be spammed). Source Code (and homework): DevForge.com/downloads/?code=IntroToUnitTesting - Intro - Working environment - Demo application walk-through - Unit Testing explained - Creating a Unit Test project - Setting up a test - A bad Unit Test and Test Driven Development - Opinion on Unit Testing - Shortening Test name - "Theory": Test method parameters and arguments - Testing edge cases - Testing number division - Dividing by zero - Testing methods that can throw exceptions: method returns output - Debugging the Unit Test - Testing the exceptions: method throws exception - Testing the exceptions: method argument throws exception - Testing methods that do more than one thing: what is a Unit of work? - Breaking method in to individual methods, what to test and what not to test - "Add to List" Tests: working test - "Add to List" Tests: failing test - Homework - Concluding remarks

Why it's here

3 people recommend this

What people say. Recommended as a great starter video and primer for learning unit testing and TDD with xUnit in .NET.

u/Saltypoisonin r/dotnet • Recommends

On “Need resources to learn deep dive into tdd and unit testing with xunit and moq”

A coworker sent me these a few months ago as we are transitioning into a TDD workflow. Definitely not a deep dive, but a good primer on the material and I'm sure the author has much more available. [video [video

u/r3ap4rin r/dotnet • Recommends

On “Are there any tutorials/courses on testing you would recommend?”

Tim Corey has a good starter video on unit testing, starting off simple and advancing to more in depth testing of methods and exceptions. [video A good follow-up video for mocking tests is also available from him: [video

u/snakkerdkin r/dotnet • Recommends

On “Does integration testing in dot.net boil down to creating a mock repository class that just returns the value expected, and then import it instead of the actual one and then test it?”

Nick Chapsas has plenty free videos on unit testing: link to this video (He also sells courses on his own course site dometrain.com) There is also Tim Corey: link to this video For .net 5+ i would recommend xunit personally, even Microsoft uses xunit for the runtime unit tests over their own testing framework.