Code Monkey home page Code Monkey logo

hedgehog-stateful-demo's Introduction

hedgehog-stateful-demo

This repository contains some code demonstrating testing of a stateful, database-backed application using Hedgehog, a library similar in spirit to the well-known QuickCheck library. Hedgehog comes with built-in functionality to test state machines but the API may be a slightly daunting, hence this demo.

It's based on a blog-post by Jacob Stanley: "How to use Hedgehog to test a real world, large scale, stateful app". Make sure to read it first!

Importing the Original Code

The first commit imports all code from the original blog-post up to the Generate commands section.

The second commit adds the code from the Generate commands and Execute commands sections.

The third commit adds code from the Delete some users section, which causes the tests to fail, as expected and explained in the original article.

The fourth commit applies the changes from the Fix the model section, which causes the tests to succeed again.

The fifth commit adds test-case labelling, as explained in the Check commands get used section of the original article.

The sixth commit adds business rule validation, which causes the tests to fail again, as expected. See the Assert business rules section in the original article.

The seventh commit reverts the previous one, since we don't want failing tests. Hence, the code is back to that of the Check commands get used section of the original article.

Reworking using Hedgehog State-Machine Testing

The above tests are re-implemented using the Hedgehog State-Machine testing functionality in similar commits:

  • The Generate commands and Execute commands functionality originally implemented in here is here (compare). Note these changes require a slight modification of the abort function, which clutters the diff somewhat.

  • The Delete some user functionality originally implemented here is here (compare).

  • The fixes from the Fix the model section originally implemented here is here (compare).

  • The code changes to label test-cases from the Check commands get used section originally implemented here is here (compare).

The final diff resembles the original one quite well!

Making Cabal Happy

This commit makes the changes required for cabal test to succeed.

hedgehog-stateful-demo's People

Contributors

nicolast 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.