We may earn an affiliate commission when you visit our partners.
Course image
Engineer Spock

Learn deeply the concepts and tools that you will need to build maintainable and reliable software.

Teaching Approach

Read more

Learn deeply the concepts and tools that you will need to build maintainable and reliable software.

Teaching Approach

No fluff, no ranting, no beating the air. I respect your time. The course material is succinct, yet comprehensive. All important concepts are covered. Particularly important topics are covered in-depth.

Take this course, and you will be satisfied.   

Build a solid foundation in Unit Testing with this course   

This course is all about writing effective unit tests using C# programming language and NUnit as a unit testing framework. Along the way, we will learn the concepts related to unit testing. Today unit testing is an absolutely required skill from any professional developer. Companies expect from developers to know how to write unit tests including all the most important topics such as mocking and test driven development (TDD in short). This course does not cover all the features of NUnit. This course is way more interesting.   

Learning unit testing puts a powerful and very useful tool at your fingertips. Being familiar with unit testing you can write reliable and maintainable applications. It is very hard to lead a project which is not covered by unit tests.   

Content and Overview   

This course is primarily aimed at beginner developers. It provides solid theoretical base reinforced by tons of practical material.   

We start with basics of unit testing. What is a unit test? What unit testing frameworks exist? How to run and debug unit tests. After getting acquainted with the basics, we will get to the NUnit framework. Here you’ll learn how to install the framework, set the runner. Then you’ll learn the basics of assertions and arrange-act-assert triplet. Other key features of NUnit are also covered:   

  • Running tests from the console   

  • Setup and teardown unit tests   

  • Parameterized tests   

  • Grouping and ignoring   

Practicing writing of unit tests, it’s impossible to avoid applying mocks. I like the word “test double” more, in general. By the way, you’ll learn what the difference between the following notion is:   

  • Test double   

  • Fake   

  • Dummy   

  • Stub   

  • Mock   

You’ll learn how to write test doubles manually. You will also see a simple example of how to use a mocking framework for using mocks. I’ll use NSubstitute mocking framework for demonstration.   

At the end of this section, you’ll get acquainted with two key approaches to unit testing, Classic or Detroit School and London School of unit testing.   

You’ll separately learn the basic of test-driven development. It is hard to imagine a modern professional developer who doesn’t know about TDD, so you’ll learn what it is and what it is about. You’ll see the Red-Green-Refactor triplet in action.   

I could not complete the course avoiding the best practices of writing unit tests. You’ll learn the basic concepts of the modern approach to unit testing called “pragmatic unit testing”. You’ll see what problems static classes and singletons bring regarding the unit testing. They make code harder to unit test. After that, you’ll learn the problem of extracting interfaces just for the sake of introducing shims for injecting dependencies.   

You’ll know should you write unit tests for the trivial code. You’ll learn a lot more in the course.   

So, in short, the course covers the following topics:   

  • Basic notions of Unit Testing   

  • NUnit and its features   

  • Test Doubles including fakes, dummies, stubs, spies and mocks   

  • How to write manual test doubles and how to use a mocking framework  (NSubstitute)

  • TDD, red-green-refactor triplet   

  • A great number of best practices of writing unit tests   

  • Introduction to Dependency Injection

In the end, we will recap what you have learned, and you will try to understand where you have to go further with the intention to master your skills.   

How long is this course: The course is around 7.5 hours. All are video lectures. You will be able to download all the slides and code samples used in the course.         

Keywords related to the course:

  • Visual Studio unit testing tutorial

  • NUnit unit testing tutorial

  • Dot Net testing framework

  • C# unit test framework

  • Visual Studio unit testing framework tutorial

  • csharp unit testing tutorial   

  • TDD in C#

  • NSubstitute

  • TDD

  • Test Driven Development

  • unit testing C#

Enroll now

What's inside

Learning objectives

  • Write unit tests
  • Run and debug unit tests
  • Write manual mocks
  • Write mocks with mocking framework
  • Practice test-driven development (tdd)
  • Apply best practices of writing unit tests

Syllabus

Before taking the Course
How to Ask Questions
Download Source Code and Slides
English Subtitles
Read more
Join .NET Community of Students
Write, run and debug a simple unit test.

The outline of the first section on the essentials of Unit Testing in .NET.

Learn what is a unit test in essence.

Learn what is a unit testing framework, which frameworks exist and is it so important to stick with a specific one?

Write your first unit test in Visual Studio in C# and NUnit unit testing framework.

Learn what naming conventions regarding unit test classes, unit tests and unit testing projects exist.

Learn how to run and debug unit tests in Visual Studio.

Learn what benefits do unit tests provide.

In this lecture, we will answer the question about who should write unit tests? Programmers or maybe testers?

Learn the Oath of Programmers.

Exercise: Degree Converter
Solution: Degree Converter

The conclusion of the first section on essentials of unit testing.

Use NUnit Framework for writing unit tests

The outline of the second section on basics on NUnit unit testing framework.

Learn the basics of Assertions in unit tests.

Learn how to write assertions with NUnit on practice.

Learn the Arrange-Act-Assert triplet.

Learn how to run unit tests from the Console.

Learn how to use special attributes of NUnit: SetUp and TearDown.

Learn how to use special attributes of NUnit: OneTimeSetUp and OneTimeTearDown.

Learn how to write parameterized unit tests with NUnit.

Learn how to group and ignore unit tests with NUnit.

Learn what is Code Coverage in unit testing.

Exercise: FizzBuzz
Solution: FizzBuzz
Exercise: Roman Numerals
Solution: Roman Numerals
Exercise: Stack
Solution: Stack

The conclusion of the second section on the essentials of the NUnit unit testing framework.

Write manual test doubles as well as relying on mocking frameworks.
Test Doubles and Dependency Injection

The outline of the third section on essentials of test doubles in unit testing.

Demonstration of a case when it's hard to unit test the logic.

Demo of how to refactor bad code to make it testable.

Learn the different types of test doubles such as mock, stub, spy, fake, dummy,

Learn how to write test doubles manually, without using any mocking framework.

Learn the problems related to writing manual test doubles.

Learn what is a mocking framework, which exist and which one to pick.

Learn how to write a unit test with test doubles powered by a mocking framework.

Learn the main features of NSubstitute mocking framework.

Learn the difference between Detroit School and London School of Unit Testing.

The conclusion of the third section on the essentials of mocking frameworks.

Write unit tests in a test-driven development manner.

The outline of the fourth section on essentials of Test-Driven Development.

Learn what is TDD.

Learn Red\Green\Refactoring process of TDD.

Learn what is the difference between Design Upfront and TDD.

Regular Agile Process in 200 Words
VS and R# Shortcuts
Refactoring Commands Built-In VS 2017
Fibonacci Numbers
Three Main TDD Techniques
Grabbing the Gold
FizzBuzz
Reading Roman Numerals
UpdateableSpin
Continuous Testing
Tic-Tac-Toe (Crosses and Noughts)
Assert First

The demonstration of TDD on the example of programming a simple console game.

Conclusion
Write clean and well-maintainable unit tests.

Outline of the fifth section on best practices of unit testing.

In this lecture we will answer the question "Do Unit Tests Guarantee the Success?"

Learn what is pragmatic unit testing.

Learn what are integration tests.

Learn what is a singleton design pattern and how it damages the ability to write unit tests.

Learn about the smell of header interfaces. They very often appear when we introduce them just for the sake of writing mocks.

Demo of a refactoring of untestable code to the state when it is testable (when we can write unit tests).

Learn how much test coverage is enough.

Do we need to write unit tests for trivial code?

Learn what really means the rule of a Single Concern in a single unit test.

Learn more about general best practices of writing unit tests.

Learn how to easily generate signatures of unit test methods.

Conclusion of the fifth section on the best practices of writing unit tests.

Final Quiz
BONUS LECTURE
Appendix. Intro to Dependency Injection
Outline
Definition of DIP
Dependencies
Volatile and Stable Dependencies
Definition of IoC and DI
DIP Violation Demo
Refactoring to a Better Design
Dependency Injection Techniques
Architectural Implications
Common Smells of DIP Violation
Appendix. Intro to DI. IoC-Containers
Pure DI and IoC-Containers
Building a Simple IoC-Container

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Builds a solid foundation for students new to software testing
Demonstrates how unit testing can make applications more reliable and maintainable
Introduces various unit testing techniques like mocks, stubs, unit test frameworks
Presents a practical approach to unit testing using C# and NUnit as the unit testing framework
Covers key best practices and patterns for effective unit testing

Save this course

Save Learn Unit Testing with NUnit and C# to your list so you can find it easily later:
Save

Reviews summary

Clear explanations

According to students, this course provides clear explanations and is well received by learners.
Explanations are easy to understand.
"so far it is much clear."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Learn Unit Testing with NUnit and C# with these activities:
Unit Testing in C# with NUnit
Gain insights from a book dedicated to unit testing with NUnit, solidifying your understanding of the concepts and techniques.
Show steps
  • Read through the book, focusing on the chapters relevant to this course
  • Take notes and highlight key concepts
Refresher: Basics of Unit Testing
Review the fundamentals of unit testing to strengthen your foundation and prepare you for success in this course.
Browse courses on Unit Testing
Show steps
  • Go through online tutorials or articles on unit testing concepts
  • Practice writing simple unit tests for basic scenarios
Mock Creation Exercises
Engage in hands-on practice creating various types of mocks, such as fakes, dummies, stubs, spies, and mocks.
Browse courses on Mocking
Show steps
  • Identify scenarios where mocks are necessary
  • Practice writing mocks using a mocking framework like NSubstitute
Three other activities
Expand to see all activities and additional details
Show all six activities
Local Unit Testing Workshop
Attend a workshop specifically dedicated to unit testing, providing an opportunity for hands-on practice and expert guidance.
Show steps
  • Research and find local workshops on unit testing
  • Register and attend the workshop
  • Actively participate in discussions and exercises
Test-Driven Development Project
Apply Test-Driven Development principles to a project, starting with writing tests first and then implementing the code to pass those tests.
Show steps
  • Choose a small software development project
  • Write unit tests for the project's requirements
  • Implement the code to pass the unit tests
  • Refactor and improve the code and tests as needed
Unit Testing Best Practices Guide
Consolidate your knowledge by creating a comprehensive guide on best practices for writing clean and maintainable unit tests.
Show steps
  • Research and gather information on unit testing best practices
  • Organize and structure the content in a logical manner
  • Write clear and concise explanations with examples

Career center

Learners who complete Learn Unit Testing with NUnit and C# will develop knowledge and skills that may be useful to these careers:
Unit Tester
A Unit Tester performs unit testing, a software development process that involves testing individual units of code. This course is highly relevant as it teaches the concepts and tools needed to write effective unit tests.
Software Tester
A Software Tester analyzes, tests, and evaluates software products to ensure they meet quality standards. This course is highly relevant as it teaches the concepts and tools needed to write effective unit tests, a core aspect of software testing.
Test Engineer
A Test Engineer plans, executes, and analyzes software tests to ensure the quality of software products. This course is highly relevant as it teaches the concepts and tools needed to write effective unit tests, a core aspect of software testing.
QA Analyst
A QA Analyst ensures the quality of software products by analyzing requirements, designing test cases, and executing tests. This course is highly relevant as it teaches the concepts and tools needed to write effective unit tests, a core aspect of software testing.
Quality Assurance Manager
A Quality Assurance Manager defines and implements an organization's quality assurance standards and procedures. A strong understanding of software testing is essential, making this course useful for developing the skills necessary to manage QA teams and ensure the quality of software products.
Technical Lead
A Technical Lead provides technical guidance and leadership to a team of software developers. This course could be useful in building a foundation of the knowledge and skills needed to lead and mentor software engineers, including the ability to write and evaluate unit tests.
Development Manager
A Development Manager plans, organizes, and manages the development of software products. This course could be useful in building a foundation of the knowledge and skills needed to manage software development teams, including an understanding of unit testing practices and principles.
Software Architect
A Software Architect designs and develops the overall architecture and structure of software systems. This course could be useful in building a foundation of the knowledge required to develop reliable and maintainable software architectures.
Systems Analyst
A Systems Analyst gathers, analyzes, and documents system requirements to design and implement software solutions. This course may be useful in developing an understanding of the principles and practices of unit testing, which can be applied to the analysis and design of software systems.
Software Engineer
A Software Engineer uses engineering principles to design, develop, and maintain software. This course could be useful in building a foundation of the knowledge required for this role, introducing key concepts and tools for creating maintainable and reliable applications.
Software Developer
A Software Developer designs, builds, and manages computer software and applications. This course could be useful in building a foundation of the knowledge required for this role, introducing key concepts and tools for creating maintainable and reliable applications.
Data Scientist
A Data Scientist uses scientific methods and techniques to extract knowledge and insights from data. This course may be useful in developing an understanding of unit testing principles and practices, which can be applied to the development of data science pipelines and algorithms.
Business Analyst
A Business Analyst analyzes business needs and translates them into technical requirements for software developers. This course may be useful in developing an understanding of software development processes and practices, including unit testing.
Project Manager
A Project Manager plans, executes, and monitors software development projects. This course may be useful in developing an understanding of software development processes and practices, including unit testing.
Technical Writer
A Technical Writer creates and maintains technical documentation, including user manuals and training materials for software products. This course may be useful in developing an understanding of software development processes and practices, including unit testing, which can be valuable in creating accurate and informative documentation.

Reading list

We've selected eight books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Learn Unit Testing with NUnit and C#.
A comprehensive guide to unit testing for programmers, covering topics such as test-driven development, mocking, and continuous integration.
A guide to unit testing in Visual Studio, covering topics such as writing tests, debugging, and test management.
A classic book on software design patterns, covering topics such as creational patterns, structural patterns, and behavioral patterns.
A beginner-friendly guide to Java programming, covering topics such as object-oriented programming, data structures, and algorithms.
A book on software development ethics and best practices, covering topics such as professionalism, code quality, and teamwork.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Learn Unit Testing with NUnit and C#.
Master .NET and C# Unit Testing with NUnit and Moq
Most relevant
Unit Testing Dotnet (.NET) Application with xUnit .net &...
Most relevant
Introduction to Test and Behavior Driven Development
Most relevant
Mocking with Moq 4 and NUnit
Most relevant
C# Unit Testing
Most relevant
WPF and MVVM: Test Driven Development of ViewModels
Most relevant
Testing Spring Boot: Beginner to Guru
Most relevant
Testing Rust 2021 Applications
Most relevant
Advanced C++ Mocking Using Google Mock 1
Most relevant
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser