FsCheck icon indicating copy to clipboard operation
FsCheck copied to clipboard

Model-based testing examples in C#?

Open baynezy opened this issue 1 year ago • 2 comments

I have been using your library for property-based testing in my C# projects and I am pretty comfortable with that. However, I now have a complex cache that I have built and wanted to use model-based testing to exercise that to make sure I have any edge cases covered.

I have been looking at your documentation and I am struggling to get my head around it as I do not know F#.

Do you have any simple examples testing something like a Dictionary in C# available? I should be able to work it out from there.

I found this article, but as I do not understand the system under test I am struggling to follow the implementation.

baynezy avatar Dec 11 '23 16:12 baynezy

@baynezy I have seen several interesting youtube videos where John Hughes talks about Property-Based Testing and I am pretty sure he talks about model based testing as one specific strategy. The same is true also for Scott Wlaschin. Hopefully these will provide some guidance.

isberg avatar Jan 15 '24 10:01 isberg

Hey, yes the docs leave much to be desired. That seems to be the general tune as I work through the backlog of issues!

Anyway, this may get you started: https://aaronstannard.com/fscheck-property-testing-csharp-part2/

There's also a hidden implementation of a model-based test for an Erlang-like process registry here: https://github.com/fscheck/FsCheck/blob/master/src/FsCheck/Script.fsx#L44 but it is F#.

If you get something working, please consider sending a PR to the docs...even if it's just a C# snippet we can put somewhere.

kurtschelfthout avatar Feb 24 '24 10:02 kurtschelfthout