Schmancy HTTP Api Testing

HTTP testing and API testing made easy

Schmancy is a library dedicated to help developers write tests against APIs without the need of setting up a server or using a real endpoint. Inspired by WebMock Schmancy lets you specify requests for a particular URl indicating query parameters, HTTP method to use, encoding, etc and what to send as a result. Under the covers uses Nancy to host the fake app and handle requests.

Quick start

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
open FsUnit
open NUnit.Framework
open RestSharp
open Schmancy

[<Test>]
let ``Calling a GET request from root`` () =
    let url = "http://localhost:8899"

    stubRequest url RequestType.Any "/"
        |> withStatus Nancy.HttpStatusCode.OK
        |> hostWith (fun _ -> 
            let response = client.Execute(new RestRequest("/", Method.GET))
            response.StatusCode
        )
        |> should equal System.Net.HttpStatusCode.OK
Fork me on GitHub