Welcome to FakeHttp.
FakeHttp is a .NetStandard library that allows you to "fake" calls to RESTful services. The advantages of faking http responses in unit tests are:
- Faking decouples test results from service implementation, resulting in more focused and better tests.
- Faked responses allow test code to operate on known test cases. This keeps unit test from becoming integration tests.
- Faking allows client code to be tested under simulated service conditions. This enables fine grained control over headers and content without special service versions. (Especially handy when you don't control the service but you need to simulate difficult to reproduce behavior)
- Faking can dramatically improve the performance of http client tests by removing internet latency.
How does FakeHttp work?
FakeHttp works by deriving from HttpMessageHandler. It can capture and store actual service responses and cache them locally as JSON files (headers and content). These can then be tweaked, committed to source control and used for subsequent unit testing.
Where to from here?
- Get the Nuget Pacakge
- Getting Started
- API Documentation
- Take a look at the source code
- Advanced Topics