Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Beginners Guide to Unit Testing with NUnit and C#
Rating: 4.2 out of 5(986 ratings)
21,902 students

Beginners Guide to Unit Testing with NUnit and C#

Learn the basics of unit testing with NUnit and C#.
Created byEngineer Spock
Last updated 7/2020
English
English [Auto],

What you'll learn

  • Write simple unit tests in C# using the NUnit framework

Course content

2 sections34 lectures1h 52m total length
  • About the Course0:27
  • Download Source Code and Slides0:04
  • Join .NET Community of Students0:02
  • BONUS0:35
  • Outline0:58

    Explore the basics of unit testing, including what unit tests are, frameworks exist, naming conventions, how to run and debug tests, and the benefits and who should write them.

  • What is a Unit Test?3:11

    Describe a unit test as a function that calls another function and verifies the outcome, with the system under test isolated from dependencies and faster, more reliable than integration tests.

  • Unit-Testing Frameworks3:25

    Explore popular unit testing frameworks such as NUnit, xUnit, and MSTest, and learn that once you master any framework, you can write tests across tools with minimal difference.

  • First Unit Test8:49

    Create a dedicated unit test project in Visual Studio, install NUnit and the NUnit 3 test adapter, and write a passport method test using test fixture and test attributes.

  • Naming Conventions4:34

    Learn naming conventions for NUnit and C# unit tests, including three major styles (should-descriptive method names, unit under test underscore forms, and three-part underscore names) with examples and use cases.

  • Running and Debugging Tests in Visual Studio5:02

    Navigate Visual Studio's test explorer to build, discover, and run NUnit tests, create test playlists, run or debug individual tests with breakpoints, group tests, and enable test execution after builds.

  • Benefits of Unit Testing3:35

    Unit tests verify that parsing methods work correctly, catching regressions before shipping and speeding development. They provide a safety net for continuous integration, guiding when and who writes tests.

  • Who should write unit tests and When?2:51

    Discover why developers must write unit tests, the role of testers in manual testing, and how unit tests provide a fast safety net for code changes.

  • Programmer's Oath3:29

    Explore programmer responsibility and the role of unit testing and test-driven design in ensuring safe, reliable software through vows of honesty, frequent incremental releases, and continuous improvement.

  • Exercise: Degree Converter1:29

    Practice unit testing with a degree converter in C#, using NUnit. Create two projects, write two tests for the Celsius and Fahrenheit methods, and follow test fixture guidelines.

  • Solution: Degree Converter6:54

    Create a degree converter tests class in the tests project, write NUnit tests for Celsius to Fahrenheit and Fahrenheit to Celsius, and run them with the test adapter to verify.

  • Conclusion1:15

    Discover how a unit test validates a unit within the system under test, explore common unit test naming templates, and learn how Visual Studio detects tests after rebuilds.

Requirements

  • Basic Skills in C#

Description

This course is all about writing unit tests using C# programming language and NUnit as a unit testing framework. Today unit testing is an absolutely required skill from any professional developer. Companies expect from developers to know how to write unit tests.

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.

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

Who this course is for:

  • Anyone who wants to learn the basic of unit testing