Published 4/2024
MP4 | Video: h264, 1920x1080 | Audio: AAC, 44.1 KHz
Language: English | Size: 419.89 MB | Duration: 1h 3m
Learn C# unit testing best practices by refactoring real-world examples.
What you'll learn
Use builder methods to simplify your tests
Write tests for multiple test values to make your tests more maintainable
Choose good names to express the intent of your tests
Use simple test values to make your tests easier to follow
Write domain-specific assertion methods to have more readable tests
Requirements
Basic knowledge of writing unit tests with a testing framework like MSTest
Understading of mocks and mocking libraries like Moq
Familiarity with the Arrange/Act/Assert pattern
Description
You've learned the basics of unit testing in C#, but you still struggle with writing tests that are easy to read and maintain.You've seen too many online tutorials testing a Calculator class, but you want to learn how to test real code. Code with dependencies, validations, and edge cases. Code that looks like the code you find every day at work.That's why I created this course.No more unit testing the Add method of a Calculator class.In this course, let's refactor some real unit tests to make them more readable and maintainable. Although I changed names, classes, and methods to avoid disclosing code from past clients and employers, these are the tests I had to work with as a software engineer. You will learn how to transform messy and convoluted tests into readable and maintainable tests using best practices and proven principles and methods.Who is this course for?This course is for you if you are:A C# developer who wants to level up your unit testing skills and write better testsA C# developer who is tired of boring and unrealistic tutorials and wants to learn from real code examplesAfter you follow this course, you will be able to:Use builder methods to simplify your testsWrite tests for multiple test values to make your tests more maintainableChoose good names and use simple test values to make your tests easier to followWrite domain-specific assertion methods to have more readable testsMastering these skills will help you to write tests easy to follow. The next time you open one of your tests, you won't need to scratch your head trying to figure out what you were doing.This is not an introductory course on unit testing. You should have some basic knowledge of writing unit tests with a testing framework like MSTest, a mocking library like Moq, and the Arrange/Act/Assert pattern.What is inside?In this course, you will get access to:Eight principles or lessons that cover different best practices for unit testingMore than ten unit tests that show real code examples that need refactoringFour exercises that challenge you to apply what you learned and refactor a unit test on your ownA checklist that summarizes the best practices from the courseSource code of all the unit tests before refactoring them
Overview
Section 1: Introduction
Lecture 1 Getting Started
Section 2: On Builders
Lecture 2 Use Builder Methods
Lecture 3 Test IOptions Interface
Lecture 4 Make Test Values Obvious
Section 3: On Testing With Multiple Values
Lecture 5 Use Parameterized Tests
Lecture 6 Use FluentValidation Helpers
Lecture 7 Use Parameterized Tests Instead of Loops
Lecture 8 Test a Single Concern Per Test
Lecture 9 Test Exception Messages
Lecture 10 Use Object Mothers
Lecture 11 Exercise: Refactor a Test That Uploads Guests
Section 4: On Mocks and Simplicity
Lecture 12 Use Fakes in Unit Testing
Lecture 13 Create Fakes With Moq
Lecture 14 Visually Structure Tests
Lecture 15 Use TypeBuilder
Lecture 16 Avoid Overspecification
Lecture 17 Use Simple Test Values
Lecture 18 Exercise: Refactor a Test That Merges Dictionaries
Section 5: On Public Behavior and Hiden Assumptions
Lecture 19 Test Public Behavior
Lecture 20 Create a Custom Verify Method
Lecture 21 Exercise: Refactor a Test That Stores an Email With Duplicated Addresses
Lecture 22 Avoid Hidden Assumptions
Lecture 23 Exercise: Refactor a Test That Updates an Email Status
Section 6: Conclusion
Lecture 24 Wrap-up
C# developers looking to improve their unit testing skills and write readable and maintainable tests,C# developers tired of boring and impractical tutorials that prefer to learn through real-world code examples
TO MAC USERS: If RAR password doesn't work, use this archive program:
RAR Expander 0.8.5 Beta 4 and extract password protected files without error.
TO WIN USERS: If RAR password doesn't work, use this archive program:
Latest Winrar and extract password protected files without error.