Course Name
Course Code : PRR39
Venue Details
Postal Code : V7Y 1G5
Session Dates
Duration: 2 days (14 hours)
Unit testing with C# training provides participants with the skills to write and execute unit tests for C# applications using popular frameworks like MSTest, NUnit, and xUnit. The course covers key concepts such as setting up test projects, writing test cases, and using assertions to verify expected behavior in code. Participants also learn how to manage test dependencies, mock objects, and handle exceptions in unit tests. Hands-on exercises focus on creating testable code, organizing tests into suites, and ensuring high code coverage through automated tests. By the end of the training, attendees will be able to apply unit testing practices in their C# development workflow, enhancing code reliability and maintainability.
Introduction to Unit Testing with C# Introduction to Unit Testing What is unit testing, and why is it essential for C# development? Key benefits of unit testing: improved code quality, early bug detection, and better maintainability. Overview of unit testing frameworks for C#: NUnit, MSTest, and xUnit. Introduction to the Test-Driven Development (TDD) methodology and its benefits. Hands-on Exercise Getting Started with NUnit and MSTest Installing and configuring NUnit and MSTest frameworks in Visual Studio. Structure of a unit test: understanding test attributes, assertions, and test lifecycle. Writing your first test using NUnit and MSTest. Hands-on Exercise Test Case Design and Best Practices Writing clear, concise, and effective test cases. Organizing test methods into logical groups using attributes like [Test], [TestFixture], and [Fact]. Naming conventions for test cases. Hands-on Exercise Assertions and Verifications Introduction to assertions: Assert.AreEqual, Assert.IsTrue, Assert.Throws, and others. Understanding and applying verification methods to check test results. Common pitfalls in assertions and how to avoid them. Hands-on Exercise Mocking Dependencies with Moq Why and when to use mocking in unit tests. Introduction to the Moq library for mocking dependencies. Creating mock objects and setting up behavior for unit tests. Hands-on Exercise Summary and Q&A Recap of key concepts learned. Q&A session to clarify any doubts or challenges faced during exercises. Advanced Unit Testing Techniques with C# Test-Driven Development (TDD) with C# The Red-Green-Refactor cycle in TDD. Writing unit tests before code: Developing software with a test-first approach. Benefits of TDD: cleaner code design and early bug detection. Hands-on Exercise: Applying TDD to write tests first, followed by code implementation. Advanced Mocking and Stubbing Mocking more complex behaviors using Moq (e.g., callbacks, events, and methods with multiple parameters). Using NSubstitute as an alternative to Moq for mocking. Hands-on Exercise Parameterized Tests and Data-Driven Testing Writing parameterized tests to handle multiple input values. Data-driven testing using attributes like [TestCase] in NUnit. Hands-on Exercise Handling Edge Cases and Exception Testing Writing tests for edge cases and exceptions (e.g., invalid inputs, boundary conditions). Using the Assert.Throws method to handle expected exceptions in unit tests. Hands-on Exercise Integrating Unit Tests into Continuous Integration (CI) Introduction to continuous integration tools like Jenkins or GitHub Actions. Setting up a CI pipeline to run unit tests automatically on each commit. Using test reports and metrics to analyze test results in CI. Hands-on Exercise Code Coverage and Test Metrics Introduction to code coverage tools like Visual Studio Code Coverage and Coverlet. Measuring and improving test coverage for C# projects. Using code coverage reports to identify untested areas in the codebase. Hands-on Exercise Final Project: Writing Comprehensive Unit Tests Applying all the concepts learned to write a comprehensive set of unit tests for a C# application. Debugging and refactoring code based on unit test results. Presenting the unit tests and discussing best practices with the group. Course Summary and Q&A Recap of all concepts learned during the course. Final Q&A session to address any lingering questions. Closing remarks and feedback on the course.
Mode of Delivery : The event can be attended both online and at nearby ProgNXT classroom by Individual Professionals and Corporate Employees as per the seat availability. Please Contact Us at [email protected] for checking the seat availability
Audience : We have a global audience that logs in to using their own computers to work hand in hand with our world-class instructors.
Assessment : Each training course will have ProgNXT Assessment at the end.
Certification : After successful passing of ProgNXT Assessment, ProgNXT Certification will be provided, which has got acceptance in 55+ Countries.
| Global Region | Location | Start Date | End Date | Action |
|---|---|---|---|---|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |