Unit Testing in C#
"Ik schreef al een tijdje unittests in C#, maar vooral geleerd door gewoon te doen en af te kijken van wat anderen deden. Met deze cursus een fijne onderbouwing van waarom dingen op en bepaalde manier juist wel/niet gedaan worden en welke mogelijkheden er zijn. Leuke trainer, goed tempo, dus wel een aanrader!" - 22-05-2024 12:19
"Ik schreef al een tijdje unittests in C#, maar vooral geleerd door gewoon te doen en af te kijken van wat anderen deden. Met deze cursus een… alles lezen - 22-05-2024 12:19
Bestge Mirjam,
Beetje laat maar nog bedankt voor je positieve feedback. Ik heb het doorgegeven aan de trainer.
Met vriendelijke groeten, Info Support
- 22-05-2024 12:19placeVeenendaal 25 feb. 2026 tot 26 feb. 2026Toon rooster event 25 februari 2026, 09:00-16:00, Veenendaal event 26 februari 2026, 09:00-16:00, Veenendaal |
placeVeenendaal 23 mrt. 2026 tot 24 mrt. 2026Toon rooster event 23 maart 2026, 09:00-16:00, Veenendaal event 24 maart 2026, 09:00-16:00, Veenendaal |
placeVeenendaal 9 apr. 2026 tot 10 apr. 2026Toon rooster event 9 april 2026, 09:00-16:00, Veenendaal event 10 april 2026, 09:00-16:00, Veenendaal |
placeUtrecht 29 apr. 2026 tot 30 apr. 2026Toon rooster event 29 april 2026, 09:00-16:00, Utrecht event 30 april 2026, 09:00-16:00, Utrecht |
Meer weten over de onderwerpen die aan bod komen en de vereiste voorkennis? Neem vrijblijvend contact met ons op.
Wees productiever door Test-Driven Development (TDD), door advanced tools en frameworks te gebruiken en best practices voor unit testing toe te passen
Beschrijving
In deze praktische training leren we je alles wat je moet weten om effectieve en onderhoudbare unit tests te schrijven met C#.
Je leert hoe je Test-driven development (TDD) kunt gebruiken om bugs vroegtijdig te ontdekken, evenals wanneer je black-box versus white-box testing moet gebruiken. We duiken ook in de wereld van mocking met de Moq mocking library, waarbij je leert waarom en hoe je dit effectief kunt gebruiken. Je leert over metrics zoals code coverage en mutation testing, en we zullen best practices bekijken die je helpen…
Er zijn nog geen veelgestelde vragen over dit product. Als je een vraag hebt, neem dan contact op met onze klantenservice.
Meer weten over de onderwerpen die aan bod komen en de vereiste voorkennis? Neem vrijblijvend contact met ons op.
Wees productiever door Test-Driven Development (TDD), door advanced tools en frameworks te gebruiken en best practices voor unit testing toe te passen
Beschrijving
In deze praktische training leren we je alles wat je moet weten om effectieve en onderhoudbare unit tests te schrijven met C#.
Je leert hoe je Test-driven development (TDD) kunt gebruiken om bugs vroegtijdig te ontdekken, evenals wanneer je black-box versus white-box testing moet gebruiken. We duiken ook in de wereld van mocking met de Moq mocking library, waarbij je leert waarom en hoe je dit effectief kunt gebruiken. Je leert over metrics zoals code coverage en mutation testing, en we zullen best practices bekijken die je helpen om efficiënte en hoogwaardige tests te schrijven. We sluiten af door implementatie van integratietests met Testcontainers, zodat je er zeker van kunt zijn dat jouw code naadloos samenwerkt met andere onderdelen van je applicatie.
Na het volgen van deze training ben je goed uitgerust om unit tests te schrijven die bugs vroegtijdig opsporen, makkelijker te onderhouden zijn en je een betere C# -ontwikkelaar maken.
AI-Boosted: Je leert hoe je unit tests kunt genereren met Github Copilot, en hoe je de uitvoer kunt beïnvloeden met een Github Copilot-instructions-bestand.
Leerdoelen
- Construct effective basic unit tests. [Apply]
- Understand the principles of the testing pyramid and its role in shaping an effective testing strategy. [Understand]
- Apply the Test-driven development (TDD) methodology when creating unit tests and production code. [Apply]
- Apply the concept of mocking in your unit tests with a common mock framework. [Apply]
- Investigate the different ways of how to measure the quality of your test code. [Analyze]
- Construct unit tests using the de facto frameworks. [Apply]
- Construct integration tests using TestContainers. [Apply]
- Explain best practices for maintainable tests. [Understand]
Onderwerpen
- About testing
- Unit testing basics
- Test-driven development (TDD)
- Concept of mocking
- Code coverage
- Mocking with MoQ
- Testing frameworks
- Best practices
- Mutation testing
- Integration testing
In this chapter, you will learn the basics of testing. Why we test and what kind of tests there are.
Goals:
- Know the difference between linting and testing.
- Learn how to categorize all the different kinds of tests.
- Know the testing pyramid and how it can help you to reason about test levels.
- Learn the common anti-patterns and how to recognize them
In this chapter, we'll learn the basics of unit testing using the practical example.
Goals:
- Learn how to define the 'unit' to test.
- Learn the difference between white-box and black-box testing.
- Learn to recognize and use naming strategies for our tests.
- Know how to determine when you are 'done' with unit testing.
- Learn basic best practices
- Lab: implement unit tests for a simple library.
In this chapter, you will learn what TDD is by example.
Goals:
- Learn TDD using the red-green-refactor cycle.
- Lab: Implement a simple library function in a TDD way
In this chapter, you will learn what 'mocking' entails and identify where you should use it by identifying your 'system under test' (SUT) and splitting from your 'dependencies'
Goals:
- Learn to identify the SUT from its dependencies
- Learn how to write a mock by hand
- Understand the need for dependency injection when working with mocks.
- Lab: implement dependency injection and setup mocking using classes.
In this chapter, we will focus on testing metrics, namely code coverage. Goals:
- Know what the difference is between code coverage and mutation testing.
- Know what kinds of coverage metrics there are and how to choose between them.
- Learn the benefits of a quick feedback cycle with code coverage.
- Learn how to run code coverage on our code using the command line.
- Know how to 'break the build' when coverage is too low.
- Lab: use code coverage to improve our tests.
In this chapter, you will learn to use a mocking library. We will focus on MoQ as an example.
Goals:
- Learn how to install MoQ in your project
- Learn the API; how to create mocks, configure them using .Setup() and verify behavior using .Verify()
- Know to use argument matchers using It.
- Lab: Implement your tests using MoQ
In this chapter, we will focus on the 2 most popular testing frameworks in .NET: MSTest and xUnit.
Goals:
- Know why we have two popular frameworks.
- Learn how their APIs compare to each other.
- Learn to parameterize our tests.
- Know what common pitfalls are and how to avoid them.
- Lab: Improve our test maintainability using features of the testing framework.
In this chapter, we will look at some best practices we can use to improve the maintainability of our tests further.
Goals:
- Know how to identify tests that are too DRY (Don't Repeat Yourself) or too WET (We Like Typing).
- Learn to prefer DAMP tests (Descriptive and Meaningful Phrases).
- Know when to use a builder pattern
- Know where to find more best practices
- Lab: Implement DAMP tests using the builder pattern.
In this chapter, we will focus on testing metrics, namely mutation testing.
Goals:
- Know what the difference is between code coverage and mutation testing
- Understand how mutation testing works conceptually.
- Learn what the "mutation score" metric is
- Learn how to use Stryker.NET to run mutation testing on C# code.
- Know how to read a mutation testing report.
- Know how to 'break the build' when the mutation score is too low.
- Lab: Improve the effectiveness of your tests using Stryker.NET.
In this chapter, we'll be 'scaling up the pyramid': Welcome to integration testing.
Goals:
- Be able to identify where an integration test is needed.
- Learn to identify 'shared state' in dependencies.
- Learn how to use Testcontainers to create dependencies on the fly.
- Know what the benefits are of using Testcontainers
- Learn to organize integration tests inside your project structure.
- Lab: Implement integration tests for a database using Testcontainers
"Ik schreef al een tijdje unittests in C#, maar vooral geleerd door gewoon te doen en af te kijken van wat anderen deden. Met deze cursus een fijne onderbouwing van waarom dingen op en bepaalde manier juist wel/niet gedaan worden en welke mogelijkheden er zijn. Leuke trainer, goed tempo, dus wel een aanrader!" - 22-05-2024 12:19
"Ik schreef al een tijdje unittests in C#, maar vooral geleerd door gewoon te doen en af te kijken van wat anderen deden. Met deze cursus een… alles lezen - 22-05-2024 12:19
Bestge Mirjam,
Beetje laat maar nog bedankt voor je positieve feedback. Ik heb het doorgegeven aan de trainer.
Met vriendelijke groeten, Info Support
- 22-05-2024 12:19Er zijn nog geen veelgestelde vragen over dit product. Als je een vraag hebt, neem dan contact op met onze klantenservice.


