Skip to content
Scotch is a .NET library for recording and replaying HTTP interactions in your test suite, it is inspired by the VCR ruby gem.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.paket Switch to Sep 24, 2018
Scotch.Tests Switch to Sep 24, 2018
Scotch Tweak dependency versions Apr 22, 2018
.gitattributes Initial commit, serialize http interaction to file Oct 5, 2015
LICENSE.txt Added release notes Apr 22, 2018 Added release notes Apr 22, 2018
Scotch.sln Fix casing Apr 22, 2018
build.bat switch to netstandard2.0 Mar 4, 2018
build.fsx Add script Sep 24, 2018
paket.dependencies Fix issue deserialising FSharp Lists Sep 26, 2018

Appveyor Build status NuGet Status


What is Scotch?

Scotch is a library for recording and replaying HTTP interactions in your test suite. This can be useful for speeding up your test suite, or for running your tests on a CI server which doesn't have connectivity to the HTTP endpoints you need to interact with.

Scotch is based on the VCR gem.

Step 1.

Run your test suite locally against a real HTTP endpoint in recording mode

//Create a HttpClient which uses a RecordingHandler
var scotchMode = ScotchMode.Recording;
var httpClient = HttpClients.NewHttpClient(pathToCassetteFile, scotchMode);
//Use this HttpClient in any class making HTTP calls
var myService = new SomeService(httpClient);

Real HTTP calls will be made and recorded to the cassette file.

Step 2.

Switch to replay mode:

var scotchMode = ScotchMode.Replaying;
var httpClient = HttpClients.NewHttpClient(pathToCassetteFile, scotchMode);

Commit the code and cassette file(s). Now when tests are run no real HTTP calls will be made, the HTTP responses will be replayed from the cassette file. Requests are currently matched on HTTP verb and URL, more customisable matching will be added in the future.

Why "Scotch"?

In keeping with the VCR theme, Scotch was a famous brand of VHS cassettes with a particularly catchy ad campaign.

You can’t perform that action at this time.