Skip to content

Commit bf0d570

Browse files
Improve docs around stateful testing.
Fixes #631.
1 parent ca637d2 commit bf0d570

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

docs/StatefulTestingNew.fsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,18 @@ But what has actually happened? Using the generators from the `Machine` methods,
108108
[(inc, 1); (dec, 0); (inc, 1); (inc, 2); (inc, 3); (inc, 4); (inc, 5);
109109
(dec, 4); (dec, 3)];
110110
TearDown = TearDown Counter;}
111-
```
111+
```
112+
113+
You can read this as a trace of the operations: the counter started off in state `0`, then using operation `inc` when to state `1`, then using operation `dec`
114+
went to state `0` and so on.
112115
113-
You can read this as a trace of the operations: the counter started off in state `0`, then using operation `inc` when to state `1`, then using operation `dec`
114-
went to state `0` and so on.
116+
This sequence is first generated using the model only, i.e. no operations are actually applied to any `Counter` objects. After generating a full trace, the operations
117+
are actually applied to the system under test, using the `Operation.Check` methods of the various `Operation` objects.
115118
116-
This sequence is first generated using the model only, i.e. no operations are actually applied to any `Counter` objects. After generating a full trace, the operations
117-
are actually applied to the system under test, using the `Operation.Check` methods of the various `Operation` objects.
119+
If a failing test is found, FsCheck will attempt to remove operations from the sequence of operations, as long as the test still fails. So in the example above,
120+
although the original sequence contains a few superfluous operations, FsCheck normally finds a shorter if not the shortest sequence that leads to the failure.
118121
119-
If a failing test is found, FsCheck will attempt to remove operations from the sequence of operations, as long as the test still fails. So in the example above,
120-
although the original sequence contains a few superfluous operations, FsCheck normally finds a shorter if not the shortest sequence that leads to the failure.
121-
*)
122+
Final tip: make the model class immutable. This makes it easier to reason about the model and the operations on it, and it also makes it easier to write the `Check` methods.
123+
If the model is mutable, you MUST make sure that the result of `Run` is a new instance of the model that you don't modify later on. FsCheck captures these results
124+
during the test run and during shrinking, and relies on them not changing.
125+
*)

docs/index.fsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ Documentation
2929
* [Running Tests](RunningTests.html) explains various ways to run FsCheck tests and how to
3030
integrate with unit testing frameworks.
3131
32+
* [Model based testing](StatefulTestingNew.html), for testing stateful systems and objects. Since this is in the Experimental namespace, semantic versioning promises do not apply to this part of the API.
33+
3234
* [Tips and tricks](TipsAndTricks.html)
3335
3436
* [API Reference](reference/index.html) contains automatically generated documentation for all types, modules
3537
and functions.
3638
37-
* [Model based testing vNext (Experimental)](StatefulTestingNew.html) is a relatively new addition for
38-
a more powerful model based testing. It's still a bit rough around the edges, some things may not
39-
work, and it is subject to change (i.e. no promises regarding semantic versioning and breaking changes). Regardless,
40-
feedback is very much appreciated!
39+
4140
4241
Contributing and copyright
4342
--------------------------

0 commit comments

Comments
 (0)