This library makes use of F# computation expressions 🪔✨ to hide some complexity of WebApplicationFactory
and provide the user with a domain specific language (DSL) for integration tests.
An "antique" C# API (👴🏽🦖🦕) is also available since v.1.1 for enhanced accessibility 😺.
Access the documentation website for more info on how to use this library.
sequenceDiagram
participant TestClient as Test
participant MainApp as App
participant DependencyApp as Dep
TestClient->>MainApp: GET /Hello
MainApp->>DependencyApp: GET /externalApi
DependencyApp-->>MainApp: Response
MainApp-->>TestClient: Response
open ApiStub.FSharp.CE
open ApiStub.FSharp.BuilderExtensions
open ApiStub.FSharp.HttpResponseHelpers
open Xunit
module Tests =
// build your aspnetcore integration testing CE
let test = new TestClient<Startup>()
[<Fact>]
let ``Calls Hello and returns OK`` () =
task {
let client =
test {
GETJ "/externalApi" {| Ok = "yeah" |}
}
|> _.GetFactory()
|> _.CreateClient()
let! r = client.GetAsync("/Hello")
}
F# is a great language, but it doesn't have to be scary to try it. Integration and Unit tests are a great way to introduce F# to your team if you are already using .NET or ASPNETCORE.
In fact you can add an .fsproj
within a C# aspnetcore solution .sln
, and just have a single F# assembly test your C# application from F#, referencing a .csproj
file is easy! just use regular dotnet add reference command.
- Search for an open issue or report one, and check if a similar issue was reported first
- feel free to get in touch, to fork and check out the repo
- test and find use cases for this library, testing in F# is awesome!!!!
- more info on F# xunit testing.
- more general info on aspnetcore integration testing if you use Nunit instead.
- aspnetcore integration testing docs in C#