Giter VIP home page Giter VIP logo

visualizing-eunit-tests's Introduction

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} = eunit_to_fsm:dynamic("../examples/frequency_tests.erl",
                                                          [],fun({M,F,A}) when {M,F}=/={frequency,init} -> {M,F,A} end).
   The abstraction function removes calls to frequency:init/1 from the trace. In order to remove other calls, just make sure the abstraction function is undefined for those values.

- Visualize the state machine:
   bluefringe:dot({Pos,Neg}).



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.





visualizing-eunit-tests's People

Contributors

palas avatar simonjohnthompson avatar thomasarts avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.