From the course: C# Test-Driven Development

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Introduction to mocking

Introduction to mocking - C# Tutorial

From the course: C# Test-Driven Development

Introduction to mocking

- [Instructor] More often than not, the system under test has dependencies and those dependencies may have their own unit tests. Therefore we do not want to test the dependencies we want to test our system under test. But what do we do when those dependencies have functionality that we don't really need to run because we trust those dependencies? For instance, when we have a database and do not want to write to the database as part of our test of our own system under test. In that case, we might consider using so-called test doubles. So we have specific objects that can behave like the dependency but are not the dependency. There are different kinds of that. The first and probably most well-known term is that of a mock. A mock handles so-called indirect outputs of the system under test. So, it's an object with properties and with methods and they implemented and so among other things, the mock knows which methods were called, how often they were called, et cetera, et cetera. And…

Contents