We may earn an affiliate commission when you visit our partners.
Course image
Mosh Hamedani

Picture this: you make a simple change to the code and suddenly realize that you created a dozen unexpected bugs. Sound familiar? You’re not alone.

Good news is, unit testing can make this a thing of the past.

Read more

Picture this: you make a simple change to the code and suddenly realize that you created a dozen unexpected bugs. Sound familiar? You’re not alone.

Good news is, unit testing can make this a thing of the past.

Maybe you’ve heard of automated or unit testing before and you’re keen to learn more.

Or perhaps you’ve tried to learn it and got a bit lost or ended up with fat and fragile tests that got in the way and slowed you down.

Either way, what you need is a course that will teach you all you need to know about this essential skill - from the basics, right through to mastery level.

What is unit testing?

In a nutshell: it’s the practice of writing code to test your code and then run those tests in an automated fashion.

Why learn unit testing?

Why write extra code? Wouldn’t that take extra time to write? Would that slow you down? Why not just run the application and test it like an end user?

Thinking like this is the mistake lots of people make. I used to make it myself. I’ve had to learn the hard way.

I learned pretty fast that if you’re building a complex application or working on a legacy app, manually testing all the various functions is tedious and takes a significant amount of time.

As your application grows, the cost of manual testing grows exponentially. And you’re never 100% sure if you’ve fully tested all the edge cases. You’re never confident that your code really works until you release your software and get a call from your boss or an end user.

Several studies have shown that the later a bug is caught in the software development lifecycle, the more costly it is to the business.

Automated tests help you to catch bugs earlier in the software development lifecycle, right when you’re coding. These tests are repeatable. Write them once and run them over and over.

The benefits of using unit tests are:

  • help you to catch and fix bugs earlier, before releasing your app into production
  • help you to write better code with less bugs
  • help you to produce software with better design - extensible and loosely-coupled
  • give you rapid feedback and tell you if your code *really* works
  • force you to think of edge cases that you didn’t realize existed
  • test your code much faster
  • tell if you have broken any functionality as you write new code
  • allow you to refactor your code with confidence
  • act as documentation about what your code does
  • save you both time and money

A valuable skill for senior developers

More and more companies are recognizing the advantages of automated testing, that’s why it’s a must-have for senior coders. If you’re looking to reach the higher levels in your coding career, this course can help.

You don’t need any prior knowledge of automated testing. You only need 3 months of experience programming in C#.

With this course you’ll learn:

  • senior coder secrets - best practices to write great unit tests
  • tips and tricks to keep your tests clean, trustworthy and maintainable
  • the pitfalls to avoid – anti-patterns
  • how to refactor legacy, untestable code into loosely-coupled and testable code
  • all about dependency injection – the one thing every coder needs to know
  • the power of mocks – when and how to use them and when to avoid

You’ll get:

  • 6 hours of HD video
  • tutorials and guidance from a senior coder with 15+ years’ experience
  • exercises with step-by-step solution
  • downloadable source code
  • lifetime access
  • access online or offline at any time on any device
  • certificate of completion to present to your current or prospective employer
Enroll now

What's inside

Learning objectives

  • Learn unit testing from scratch
  • Tips and tricks to write clean, maintainable and trustworthy tests
  • Write loosely-coupled and testable code
  • Refactor legacy code towards testable code
  • Understand and implement dependency injection
  • Use mocks to isolate code from external dependencies
  • Apply the unit testing best practices
  • Learn the anti-patterns to avoid

Syllabus

Getting Started
What is Automated Testing
Benefits of Automated Testing
Types of Tests
Read more
Test Pyramid
The Tooling
Source Code
Writing Your First Unit Test
Testing All the Execution Tests
Refactoring with Confidence
Using NUnit in Visual Studio
What is Test-Driven Development
Course Structure
Summary
Asking Questions
Fundamentals of Unit Testing
Introduction
Characteristics of Good Unit Tests
What to Test and What Not to Test
Naming and Organizing Tests
Introducing Rider
Writing a Simple Unit Test
Black-box Testing
Set Up and Tear Down
Parameterized Tests
Ignoring Tests
Writing Trustworthy Tests
Developers Who Don't Write Tests
Core Unit Testing Techniques
Testing Strings
Testing Arrays and Collections
Testing the Return Type of Methods
Testing Void Methods
Testing Methods that Throw Exceptions
Testing Methods that Raise an Event
Testing Private Methods
Code Coverage
Testing in the Real-world
Exercises
19- Exercise- FizzBuzz
20- Solution- FizzBuzz
Exercise- DemeritPointsCalculator
Solution- DemeritPointsCalculator
Exercise- Stack
Solution- Stack
Breaking External Dependencies
Loosely-coupled and Testable Code
Refactoring Towards a Loosely-coupled Design
Dependency Injection via Method Parameters
Dependency Injection via Properties
Dependency Injection via Constructor
Dependency Injection Frameworks
Mocking Frameworks
Creating Mock Objects Using Moq
State-based vs. Interaction Testing
Testing the Interaction Between Two Objects
Fake as Little As Possible
An Example of a Mock Abuse
Who Should Write Tests
Exercise- VideoService
Refactoring
Testing
Exercise- InstallerHelper
Refactoring InstallerHelper
Testing InstallerHelper
Exercise- EmployeeHelper
Refactoring EmployeeController
Testing EmployeeController
Project- Testing BookingHelper
Test Cases
Extracting IBooking Repository
Writing the First Test
Writing the Second Test
Fixing a Bug
Writing Additional Tests
Project- HouseKeeperHelper
Refactoring For Testability
Fixing a Design Issue
An Alternative Solution
Writing the First Interaction Test
Keeping Tests Clean
Testing a Method is Not Called
Another Interaction Test
Extracting Helper Methods
Testing Exceptions
Coupons to My Other Courses

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Builds a strong foundation for beginners who are looking to learn Unit Testing from scratch
Provides tips and tricks to write clean, maintainable, and trustworthy tests
Develops professional skills or deep expertise in Unit Testing
Taught by Mosh Hamedani, who is recognized for his work in programming
Provides exercises with step-by-step solutions to help learners practice
Offers lifetime access, allowing learners to revisit the course materials at their convenience and pace

Save this course

Save Unit Testing for C# Developers to your list so you can find it easily later:
Save

Reviews summary

Well-received c# unit testing course

According to students, this course is well received and is great for learning about unit testing for C# developers. The course covers the NUnit and Moq frameworks. Students report that this course was very helpful and that the instructor, Mosh Hamedani, is knowledgeable. Students also appreciate that this course is self-paced and affordable.
Self-paced and affordable
"This course is self-paced and affordable."
Covers NUnit and Moq frameworks
"The course covers the NUnit and Moq frameworks."
Knowledgeable instructor
"Mosh Hamedani is a knowledgeable instructor."

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 Unit Testing for C# Developers with these activities:
Review Fundamentals
Review basic automated testing principles to refresh and strengthen your knowledge foundation.
Show steps
  • Revisit the course description and learning objectives for this course.
  • Familiarize yourself with the terminology of automated testing and unit testing.
  • Review the benefits and advantages of using automated testing.
Write Unit Tests for Simple Functions
Practice writing basic unit tests to gain hands-on experience.
Show steps
  • Choose a simple function from the course materials or find one online.
  • Write unit tests that cover various scenarios and edge cases.
  • Run the tests and debug any failures.
Participate in a Peer Review Session
Engage with other students and provide feedback on unit testing practices and techniques.
Show steps
  • Find a study group or online forum.
  • Share your unit test code and best practices with the group.
  • Provide constructive feedback and learn from others.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Follow Tutorials on Test-Driven Development
Explore test-driven development principles and techniques through guided tutorials.
Show steps
  • Find online tutorials or courses on test-driven development.
  • Follow the tutorials and apply the principles to your own projects.
  • Seek guidance from experts or experienced developers if needed.
Read 'Working Effectively with Legacy Code'
Gain insights into techniques for working with and refactoring legacy code to improve its testability and maintainability.
View Brutal Refactoring on Amazon
Show steps
  • Obtain a copy of the book.
  • Read and study the chapters on refactoring and unit testing.
  • Apply the techniques to your own projects or legacy codebase.
Develop a Unit Testing Framework for a New Project
Apply your knowledge by creating a unit testing framework for a new project to ensure testability from the start.
Show steps
  • Design a testing framework that meets the requirements of your project.
  • Implement the framework using appropriate testing libraries and tools.
  • Document and share the framework with your team or the community.
Write a Blog Post on Unit Testing Best Practices
Share your knowledge and insights by summarizing best practices and techniques for effective unit testing.
Show steps
  • Review the course materials and research best practices for unit testing.
  • Organize your thoughts and outline the key points.
  • Write a well-structured blog post that clearly explains the best practices.

Career center

Learners who complete Unit Testing for C# Developers will develop knowledge and skills that may be useful to these careers:
Software Developer
Software Developers write code to create products and services. These applications can be used on computers, phones, and other devices. Software Developers are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Software Developer by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Software Developers as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Test Engineer
Test Engineers design and execute tests to ensure that software meets customer requirements. They work on a variety of projects, from small personal apps to large enterprise systems. Test Engineers are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Test Engineer by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Test Engineers as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Software Engineer
Software Engineers design, develop, and maintain software systems. They work on a variety of projects, from small personal apps to large enterprise systems. Software Engineers are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Software Engineer by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Software Engineers as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Quality Assurance Analyst
Quality Assurance Analysts work to ensure that software is of high quality and meets customer requirements. They work on a variety of projects, from small personal apps to large enterprise systems. Quality Assurance Analysts are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Quality Assurance Analyst by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Quality Assurance Analysts as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Software Tester
Software Testers test software to find bugs and ensure that it is working as intended. They work on a variety of projects, from small personal apps to large enterprise systems. Software Testers are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Software Tester by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Software Testers as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Computer Programmer
Computer Programmers write code to create software applications. They work on a variety of projects, from small personal apps to large enterprise systems. Computer Programmers are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Computer Programmer by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Computer Programmers as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Software Architect
Software Architects design and develop the architecture of software systems. They work on a variety of projects, from small personal apps to large enterprise systems. Software Architects are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Software Architect by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Software Architects as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Computer Scientist
Computer Scientists研究计算机科学的基本原理。他们开发新技术和算法,以解决实际问题。 Computer Scientists are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Computer Scientist by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Computer Scientists as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Technical Writer
Technical Writers create documentation that explains how to use software and other technical products. They work on a variety of projects, from small personal apps to large enterprise systems. Technical Writers are in high demand as businesses increasingly rely on technology. This course can help you get started in a career as a Technical Writer by teaching you the basics of unit testing in C#. Unit testing is an essential skill for Technical Writers as it helps to ensure that code is working as intended. This course will give you the skills you need to succeed in this role.
Project Manager
Project Managers are responsible for planning and executing projects. They work on a variety of projects, from small personal apps to large enterprise systems. Project Managers are in high demand as businesses increasingly rely on technology. This course may be useful for Project Managers as it can help them to understand the technical aspects of software development. This understanding can be helpful in managing software development projects.
Systems Analyst
Systems Analysts design and implement computer systems. They work on a variety of projects, from small personal apps to large enterprise systems. Systems Analysts are in high demand as businesses increasingly rely on technology. This course may be useful for Systems Analysts as it can help them to understand the technical aspects of software development. This understanding can be helpful in designing and implementing computer systems.
Product Manager
Product Managers are responsible for the development and launch of new products. They work on a variety of projects, from small personal apps to large enterprise systems. Product Managers are in high demand as businesses increasingly rely on technology. This course may be useful for Product Managers as it can help them to understand the technical aspects of software development. This understanding can be helpful in making decisions about product features and functionality.
Web Developer
Web Developers design and develop websites. They work on a variety of projects, from small personal websites to large enterprise websites. Web Developers are in high demand as businesses increasingly rely on the internet to reach customers. This course may be useful for Web Developers as it can help them to understand the technical aspects of web development. This understanding can be helpful in designing and developing websites.
Database Administrator
Database Administrators manage and maintain databases. They work on a variety of projects, from small personal apps to large enterprise systems. Database Administrators are in high demand as businesses increasingly rely on data to make decisions. This course may be useful for Database Administrators as it can help them to understand the technical aspects of database management. This understanding can be helpful in managing and maintaining databases.
Data Analyst
Data Analysts collect, analyze, and interpret data to help businesses make informed decisions. They work on a variety of projects, from small personal apps to large enterprise systems. Data Analysts are in high demand as businesses increasingly rely on data to make decisions. This course may be useful for Data Analysts as it can help them to understand the technical aspects of data analysis. This understanding can be helpful in collecting, analyzing, and interpreting data.
Business Analyst
Business Analysts work with businesses to identify and solve problems. They work on a variety of projects, from small personal apps to large enterprise systems. Business Analysts are in high demand as businesses increasingly rely on technology to solve problems. This course may be useful for Business Analysts as it can help them to understand the technical aspects of software development. This understanding can be helpful in working with businesses to identify and solve problems.

Reading list

We've selected 14 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 Unit Testing for C# Developers.
A good starting point for those new to testing principles and practices. Provides a brief introduction to testing as well as details about how to write and run unit tests. Considered to be one of the key foundational texts on TDD.
Is about patterns and best practices for writing good unit tests for C# applications. Recommended for those who want to write clean, maintainable, and readable tests. Provides good coverage of design patterns and refactoring techniques.
A classic work on refactoring, a technique for improving the design of existing code without changing its behavior. provides a systematic approach to refactoring and discusses many specific refactoring techniques. It must-read for all software developers who want to write clean and maintainable code.
Focuses on writing clean and maintainable code. It discusses topics such as naming conventions, formatting, and refactoring.
Domain-driven design (DDD) software development approach that focuses on creating software systems that are closely aligned with the domain that they represent. provides a comprehensive overview of DDD concepts and best practices. Recommended for those working on complex software projects and for those interested in learning more about software design.
Legacy code is code that was written in the past and is still in use today. provides practical advice on how to work effectively with legacy code. It covers topics such as understanding legacy code, refactoring legacy code, and testing legacy code.
Continuous delivery software development approach that enables organizations to deliver software updates frequently and reliably. provides a comprehensive overview of continuous delivery practices and techniques. Recommended for those interested in learning more about continuous delivery.
DevOps software development approach that emphasizes collaboration between development and operations teams. provides a comprehensive overview of DevOps practices and techniques. Recommended for those interested in learning more about DevOps.
A comprehensive guide to software construction, covering topics such as requirements gathering, design, testing, and maintenance.
Agile testing software testing approach that is based on the Agile development process. provides a comprehensive overview of agile testing practices and techniques. Recommended for those working on Agile projects.
Stresses best practices and in advocating pragmatic solutions over purely academic ones. It provides background knowledge in software development and discusses topics such as requirements, design, testing, debugging, and management. Recommended as additional reading and as a professional development resource.
A collection of 50 specific ways to improve your C# code with actionable advice. Discusses topics such as object-oriented design and best practices. Useful for all C# developers regardless of their skill level.

Share

Help others find this course page by sharing it with your friends and followers:
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