Git Product home page Git Product logo

calculator's Introduction

Mayhem Testing Example

Welcome to a simple example of how Mayhem can be used to improve a simple calculator app. In a nutshell, Mayhem tries to test your app like a hacker and help you check high level requirements in addition to specific unit tests.

Check out the PR to see how Mayhem works by:

  • Performing security testing. Security testing searches and proves vulnerabililties
    such as memory safety and logical bugs that violate a program invariant.

  • Improving coverage. Mayhem continually looks for untested code and then writes a test case for it. The algorithm works as follows. Mayhem runs the app on a specific input, and notices which code branches are not executed. Those code branches are added to a queue. Mayhem then processes the queue and tries to write a test case that triggers a previously untested branch. Over time, this process helps grow your test suite to get more code coverage.

  • Checking requirements with property testing. Unit tests only check a single test case, thus are insufficient for checking that general requirements hold. Property testing extends unit testing to check that all variations of a test satisfy an output condition.

    For example, Mayhem can check "A * B / A = B", while normal unit tests can only check specific cases like "3 * 2 / 3 = 2".

Quick start

You can build this application quickly in two ways:

# docker build.
make docker

# On-system build. Requires make and a C compiler.
make all

Running Mayhem

  1. Go to https://mayhem.security and create an account.
  2. Build the docker image as given in the quick start. Push the docker image to a public docker registry
  3. Edit tests/Mayhemfile to point to your docker image.
  4. Run mayhem run -f tests/Mayhemfile.

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.