Skip to content

This project aims to visualize test cases written in Erlang in a graphical finite state machine representation. The aim is to visually evaluate the quality of a test suite.

License

Notifications You must be signed in to change notification settings

ThomasArts/Visualizing-EUnit-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.





About

This project aims to visualize test cases written in Erlang in a graphical finite state machine representation. The aim is to visually evaluate the quality of a test suite.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •