[go: up one dir, main page]

Skip to content
/ scotch Public

Scotch is a .NET library for recording and replaying HTTP interactions in your test suite, it is inspired by the VCR ruby gem.

License

Notifications You must be signed in to change notification settings

mleech/scotch

Repository files navigation

Appveyor Build status NuGet Status

Scotch

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.

About

Scotch is a .NET library for recording and replaying HTTP interactions in your test suite, it is inspired by the VCR ruby gem.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published