https://github.com/stijnmoreels/fscenario
Reusable integration test building blocks to make writing integration tests more fun.
https://github.com/stijnmoreels/fscenario
assert assertions clean-up defect-localization disposable filesystem fixture fsharp functional http integration-testing integration-tests no-stress open-minded performance-tests polling reliable scenario-tester testing zero-waste
Last synced: 20 days ago
JSON representation
Reusable integration test building blocks to make writing integration tests more fun.
- Host: GitHub
- URL: https://github.com/stijnmoreels/fscenario
- Owner: stijnmoreels
- License: unlicense
- Created: 2018-12-11T15:47:56.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-11-26T10:37:27.000Z (over 2 years ago)
- Last Synced: 2025-03-24T07:26:43.399Z (about 1 month ago)
- Topics: assert, assertions, clean-up, defect-localization, disposable, filesystem, fixture, fsharp, functional, http, integration-testing, integration-tests, no-stress, open-minded, performance-tests, polling, reliable, scenario-tester, testing, zero-waste
- Language: F#
- Homepage: https://stijnmoreels.github.io/FScenario/
- Size: 10.2 MB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# FScenario
FScenario is a .NET project to help developers writing more safe integration tests but also to make the developing more fun.
The project contains several ways to help the developer to clean up in after the integration test has run, polling mechanisms to make the assertion phase more reliable, building blocks to create your own disposable fixture, ...
## Information
Following resources contains some extra information about this library:
* [FScenario Wiki](https://stijnmoreels.github.io/FScenario/)
* [Reusable Integration Test Building Blocks with F# FScenario and C# Interop](https://www.codit.eu/blog/reusable-integration-test-building-blocks-with-f-fscenario-and-c-interop/)## NuGet
[](https://www.nuget.org/packages/fscenario)
## Build Status
| Mono | .NET |
| ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [](https://travis-ci.org/stijnmoreels/FScenario) | [](https://ci.appveyor.com/project/stijnmoreels/fscenario/branch/master) |## Examples
The project exposes several reusable building blocks to make your integration/scenario test more reliable in seconds.
Several test fixtures to test file system related functionality:
```fsharp
open System.IO
open Expecto
open FScenariolet startYourApplication = ignore
[]
let file_tests =
testCaseAsync "should poll for file presence" <| async {
Dir.clean "."
do startYourApplication
let! f = Poll.untilFileExistsEvery1sFor5s "some-file.txt"
FileInfo.delete f
};
```Several test fixtures to test HTTP functionality or HTTP callbacks from your applications without any big setup.
```fsharp
open Expecto
open FScenario[]
let http_tests =
testCaseAsync "starts http server and GET -> OK" <| async {
let endpoint = "http://localhost:8080"
use _ = Http.server endpoint
do! Poll.untilHttpOkEvery1sFor5s endpoint
use! res = Http.get endpoint
Expect.equal OK res.StatusCode "http status code should be OK"
};
```And a lot more building blocks that are written in such a generic way, you can use it anywhere.
```fsharp
async {
do! Poll.target (fun () -> async { return Dir.files "my-dir" })
|> Poll.until (Seq.length >> (=) 3)
|> Poll.every _1s
|> Poll.timeout _10s
|> Poll.error "Directory 'my-dir' should have 3 files" }
```With full C# support!
```csharp
Poll.Target(() => Task.FromResult(Dir.Files("my-dir")))
.Until(fs => fs.Length == 3)
.Every(TimeSpans._1s)
.For(TimeSpans._10s)
.Error("Directory 'my-dir' should have 3 files);
```