-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
36 lines (22 loc) · 1.68 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This program takes a set of EUnit tests and generates a state machine that represents the state transitions of the System Under Test.
In order to make this work, you need an EUnit test suite that contains both positive and negative tests, i.e., have tests with ?assertError (alt. any variant of it).
How to get negative tests.
If you use defensive programming, you may have an API that returns errors instead of crashes.
At the moment, we cannot recognize negative traces of that form (work in progress). That is if you match on error values ?assertMatch({error,Reason},....), then please rewrite this to
?assertError(case .... of {error,Reason} -> exit(error); Other -> Other end).
How to build
Install GraphViz if you want to visualize the state machines.
In ebin directory type "erl -make" or in Erlang shell "make:all()".
How to run
The main API is in the module eunit_to_fsm.erl.
There is one example, in the examples directory. We use this in our explanation
- Make sure your path is such that you can run your EUnit tests.
- In order to generate traces:
{{Pos,Neg}, Tree} = eunit_to_fsm:dynamic("../examples/frequency.erl", []).
- Generate an abstract state machine with
bluefringe:qsm({Pos,Neg}).
- Visualize the state machine:
bluefringe:dot({Pos,Neg}).
- Create a QuickCheck template with:
bluefringe_fsm:eqc_fsm(bluefringe:qsm({Pos,Neg}), frequency, Tree).
The tracing is defined in the function eunit_tracing:t/1. If you happen to have other tracing running during EUnit execution, then you need to modify this function to makes sure our implementation gets the right trace data. Having additional events is no problem, you can filter them by providing an abstraction function.