C# Unit Testing with xUnit

blur

Learn Path Description

Unit testing has become standard practice for today's software developers and xUnit is one of the most popular unit testing frameworks available for .NET. The goal of this learning path is to help you understand how to write clean, testable code, all the way from writing your first test to mocking out dependencies to developing a pragmatic suite of unit tests for your application.

Skills You Will Gain

Courses In This Learning Path

blur
icon

Total Duration

2.47 hours

icon

Level

Intermediate

icon

Learn Type

Certifications

Testing .NET Code with xUnit.net 2: Getting Started

After software bugs are released to production, it is often more costly, time-consuming and stressful to fix them. Automated tests are a good way to ensure that your application works as it should and to stop bugs from reaching production. This course, Testing.NET Code withxUnit.net 2 - Getting Started, will give you an overview of automated testing and enable you to begin testing your own applications. You'll first learn how to set up automated tests with xUnit.net that can verify various types of results. Next, you will learn how to control and customize test execution and categorization. You'll also learn how data-driven testing can reduce the amount you have to write. This course will give you a solid understanding of xUnit.net and allow you to begin writing automated tests.

blur
icon

Total Duration

135 minutes

icon

Level

Beginner

icon

Learn Type

Certifications

Mocking with Moq 4 and xUnit

Writing unit tests can be time-consuming, difficult, and slow if you don't know how to isolate the classes that you want from the rest. This course, mocking with Moq 4 & xUnit will teach you how to create mocks that you can use as dependencies for the classes you wish to test. You'll first learn how to set up mocked properties and methods to return certain values. Next, you will learn how to conduct behavior/interaction testing in order to verify that your classes interact correctly with each other. You'll also learn how to create mock exceptions and mock events, as well as other mocking techniques. This course will teach you how to use Moq to test your classes individually by creating and using mock objects.

blur
icon

Total Duration

1.26 hour

icon

Level

Intermediate

icon

Learn Type

Certifications

Creating Maintainable Contexts for Automated Testing

This course will show you how to create a typical test context. It will also explain the factors that can make it fragile and difficult to maintain. We can use software principles that we are all familiar with and patterns that we might not have seen before to create contexts that focus on the most important information to understand what your tests are trying tell you. The Object Mother pattern is a common way to create test contexts. We will start with the general principles. We'll then move on to the Object Builder, a modern, expressive version of the Object Mother. You'll also learn how to use Roslyn C# scripts for the repetitive parts of the Object Builder patterns so you can get to the fun stuff. This course will give you an understanding of what makes a good test environment and how to use it in your current and future projects.

blur
icon

Total Duration

2.26 hours

icon

Level

Beginner

icon

Learn Type

Certifications

Test Driven Development in C#

A solid understanding of Test Driven Development is essential to writing robust and reliable C# code. This course will teach you how to use TDD in your.NET projects. You will first learn about TDD and the red-green refactor cycle. Next, you'll learn how to implement and test business logic in a.NET Core app using TDD. As a testing framework, you'll use xUnit and Moq to mock your code. Your business logic will be implemented in an ASP.NET Core Razor Pages app. You will also use TDD to add new features. This course will give you a solid foundation in Test Driven Development, which will be useful as you test and implement new features within your C# projects.

blur
icon

Total Duration

2.02 hours

icon

Level

Beginner

icon

Learn Type

Certifications

Writing Testable Code

Testable code is code that automates automated testing quickly, easily, and enjoyably. This course, Writing Testable Code teaches you how to create code that is easy for testing. These skills will allow you to easily refactor difficult-to-test code into testable code. You'll learn how to make your code testable by creating seams. Next, you will learn best practices to make testing code easier, such as simplifying object construction and working with dependencies. Finally, you will be able to manage application state. You'll also learn best practices by observing a code demonstration of each practice to see how it's implemented. This will make unit testing much easier. You'll be able to write testable code by the end of the course.

blur
icon

Total Duration

1.59 hour

icon

Level

Beginner

icon

Learn Type

Certifications

.NET Unit Testing with AutoFixture

Automated testing can be costly and time-consuming to create.
This course, .NET Unit Testing using AutoFixture will teach you how to use AutoFixture for anonymous test data generation.

First You'll learn how AutoFixture can generate anonymous test data for basic and custom types.
Next You'll find powerful ways to customize and control how AutoFixture generates anonymous tests objects.
Learn how to drastically reduce the amount test code that you have to write. Use AutoFixture to automatically create and test the object you are testing, as well as mock dependencies.

After completing this course, AutoFixture knowledge and skills will be your foundation for writing unit tests faster and more easily.

blur
icon

Total Duration

0.39 hour

icon

Level

Intermediate

icon

Learn Type

Certifications

Improving Unit Tests with Fluent Assertions

It can be difficult to determine the cause of test failures when they occur. Sometimes, test failure messages that are unclear or not sufficiently detailed can make it difficult to understand why the tests failed. To find out the cause of the failures, you may need to open the debugger and put the test in debug mode. This course, Improving Unit Tests using Fluent Assertions will teach you the basics of Fluent Assertions. You will first learn how to make your test code more readable. You will then explore how to assert on different types of result such as strings and floating point numbers. You will also learn how to improve test fail messages so that you don't waste time fixing failing tests. This course will equip you with the knowledge and skills to use Fluent Assertions to increase readability and test fail messages for automated tests.

blur