Project

gen-test

0.0
No release in over 3 years
Low commit activity in last 3 years
Generative / Property testing
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0
~> 0.9.24

Runtime

~> 1.9.6
 Project Readme

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