Sitemap
About Coding

A collection of coding discoveries (stories) as i continuously learn and work in the software industry

Stubbing External APIs in Unit Tests

3 min readSep 26, 2018

--

Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what’s programmed in for the test.

Mocks are what we are talking about here: objects pre-programmed with expectations which form a specification of the calls they are expected to receive.

WireMock.Net is a flexible library for stubbing and mocking web HTTP responses using requests matching and response templating

Install-Package WireMock.Net -Version 1.0.4.17

Press enter or click to view image in full size
Setting up the Stub Server
Press enter or click to view image in full size
HTTP Post to the stub Server
Press enter or click to view image in full size
Response to “/searches” call
Press enter or click to view image in full size

--

--

About Coding
About Coding

Published in About Coding

A collection of coding discoveries (stories) as i continuously learn and work in the software industry