Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a Generative Unit Test Framework?

Tags:

mbunit

On stackoverflow I've come across mbunit. On its page it states that mbunit is a generative unit test framework, but I can't find anywhere that describes what a Generative unit test framework is.

I was hoping to get :

  • A definition
  • Links to articles about what a Generative Unit Test framework is and isn't.
like image 886
Nikola Stjelja Avatar asked Feb 18 '09 21:02

Nikola Stjelja


People also ask

What is a generative test?

In a generative test the engineer describes the shape of the data, and then defines the properties that the results should have, and the test runner provides randomized data to check against.

What is MbUnit testing?

MbUnit (previously named GUnit) is a generative test unit framework, built for C sharp testing. MbUnit implements the Simple Test Pattern and makes it really easy to use fixtures.


1 Answers

A generative testing framework is one where the code itself generates test cases.

Typically you write code to generate test cases according to one or more assumptions you would like to test.

I'm not fambiliar with mbunit itself, but for example using the Clojure generative test framework test.generative you can write tests like:

(defspec integers-closed-over-addition
  (fn [a b] (+' a b))                    ;; input fn
  [^long a ^long b]                      ;; input spec
  (assert (integer? %)))                 ;; 0 or more validator forms

This test directly specifies the assumption you want to test (i.e. that the addition of two longs always results in an integer).

The important point is that you don't have to specify particular long vales for testing - the framework itself will generate arbitrary combinations of inputs and check that your assertions hold true in every case.

like image 150
mikera Avatar answered Sep 28 '22 00:09

mikera