Giter VIP home page Giter VIP logo

gen-test's Introduction

Ruby Gem Version

Gen::Test

Generative, property based testing for Ruby

Synopsis

AddOne = lambda { |x| x + 1 }

class AddOneTest < Minitest::Test
  include Gen::Test

  def test_incremented_for_all_integers
    for_all Integer do |int|
      inc = AddOne[int]
      assert_equal(inc, int + 1)
    end
  end
end

Why?

Generative or property based testing is an approach to testing where tests are automatically generated from definitions for properties of the system being tested. While slower, generative testing has much value for unit, acceptance and integration testing over TDD and BDD.

For example, generative tests still have much value when they're written after your code, and when extensive can be quite useful for integration testing.

Others argue this point well.

There seemed to be a need for a simple, extensible, implementation for Ruby, that isn't a DSL or a framework. This module strives to serve that purpose, it's still very incomplete, but it's proven useful.

You can use Gen::Test along side other tests written in a different style and it's designed to be used with other testing frameworks like Minitest and Rspec.

It's also extensible, defining a simple protocol for extensiblity. Just define a generate method that can be called with no arguments and returns your generated data on any object and it can be used as a generator.

Many core objects have already been extended (see lib/ext_core.rb). You can also make use of Gen::Generator which is a Proc-like object that implements the generate method.

Install

> gem install gen-test

or, add

gem 'gen-test'

to your Gemfile.

Extentions

See Also

gen-test's People

Contributors

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