From Zero to Hero: Testing with xUnit in C#

Learn how to test any codebase in .NET with the latest version of xUnit, the industry-standard testing library.

About This Course

Improve the quality of your C# code by learning automated testing with xUnit, the go-to framework for .NET developers. This detailed course guides you from writing your first test to applying advanced techniques. You'll cover essential topics like assertions, data-driven tests using theories, and managing the test lifecycle with fixtures. The course also covers best practices for structuring and organizing your tests for long-term maintainability. By the end, you'll be able to write effective tests for any .NET application, ensuring your code is robust, reliable, and easier to maintain.

Course Curriculum

5h 59m 11 sections
Welcome
01:21 Free preview
What will you learn in this course?
01:34 Free preview
Who is the course for and prerequisites
01:45 Free preview
Introduction
07:08
Setting Up Your First xUnit.net Project
16:09
Writing and Running Your First Tests
12:54
Section Recap
02:51
Introduction
04:07
Facts vs Theories When to Use Each
15:16
Test Structure and Organisation
14:14
Test Naming and Documentation
11:20
Section Recap
03:07
Introduction
05:07
Basic Assertions
12:07
String and Numeric Assertions
12:27
Collection Assertions
06:10
Exception Assertions
09:55
Custom Assertions and Extensions
11:45
Section Recap
02:43
Introduction
01:21
InlineData and Simple Parameterisation
07:06
MemberData and ClassData Patterns
12:32
Type-Safe TheoryData and TheoryDataRow
08:41
MatrixTheoryData and Combinatorial Testing
05:27
Section Recap
02:35
Introduction
02:18
Constructor and IDisposable Patterns
06:17
IAsyncLifetime and Async Setup-Teardown
06:43
Class Fixtures
06:29
Collection Fixtures
06:15
Assembly Fixtures
07:02
Section Recap
02:34
Introduction
01:58
Parallel Execution, Test Collections and Ordering
08:12
Dynamic Skipping and Conditional Tests
04:06
Test Timeouts and Cancellation
07:52
TestContext and Runtime Information
04:01
Section Recap
01:21
Introduction
01:05
ITestOutputHelper and Console Output Capture
13:49
Diagnostic Messages and Test Attachments
11:41
Debugging Techniques
08:10
Section Recap
01:16
Introduction
02:14
Built-in Report Formats and Coverage
11:30
Configuration Files and Runtime Settings
07:53
CI-CD Integration
07:00
Section Recap
00:54
Introduction
04:06
Custom Test Attributes and Data Sources
13:47
Test Traits
09:33
Building Reusable Test Libraries
07:57
Section Recap
01:29
Conclusion
02:05

Meet Your Instructor

Gui Ferreira

Gui Ferreira

Guilherme Ferreira, also known as Gui, is a Minimalist Software Craftsman, passionate about simplicity and continuous learning. Gui is a Microsoft MVP for Developer Technologies, a Tech Speaker, a YouTuber, and a .NET content creator. With over 15 years of experience in software development, Gui went from Startups to Tech Giants. Along his journey, he got to know several hats, including Software Engineer, Architect, CTO, and Developer Advocate, gathering a diverse and invaluable skill set.

View all courses by Gui Ferreira

What's New

Deep Dive: Solution Architecture
course

Deep Dive: Solution Architecture

Master solution architecture and turn business needs into scalable, maintainable systems.

Learn More
Migrating: ASP.NET Web APIs to ASP.NET Core
course

Migrating: ASP.NET Web APIs to ASP.NET Core

A step-by-step process to migrate ASP.NET Web APIs from .NET Framework to ASP.NET Core.

Learn More
Getting Started: Caching in .NET
course

Getting Started: Caching in .NET

Let's make the hardest thing in programming easy for .NET software engineers.

Learn More
From Zero to Hero: Testing with xUnit in C#
course

From Zero to Hero: Testing with xUnit in C#

Learn how to test any codebase in .NET with the latest version of xUnit, the industry-standard testing library.

Learn More
Create a ChatGPT Console AI Chatbot in C#
blog

Create a ChatGPT Console AI Chatbot in C#

This walkthrough is your hands-on entry point to create a basic C# console application that talks to ChatGPT using the OpenAI API.

Learn More