BDD

Behavior Driven Development testing framework for the D programming language

Home page: https://github.com/workhorsy/BDD

Members

Functions

after
AfterFunc after(void delegate() func, string file, size_t line)

The function to call after each 'it' function.

before
BeforeFunc before(void delegate() func, string file, size_t line)

The function to call before each 'it' function.

describe
void describe(string describe_message, ItFunc[] its)

Used to describe the thing being tested. Contains many 'it' functions to test the thing.

describe
void describe(string describe_message, BeforeFunc before, ItFunc[] its)

Used to describe the thing being tested. Contains many 'it' functions to test the thing. Also takes a function to run before each test.

describe
void describe(string describe_message, AfterFunc after, ItFunc[] its)

Used to describe the thing being tested. Contains many 'it' functions to test the thing. Also takes a function to run after each test.

describe
void describe(string describe_message, BeforeFunc before, AfterFunc after, ItFunc[] its)

Used to describe the thing being tested. Contains many 'it' functions to test the thing. Also takes a function to run before, and a function to run after each test.

it
ItFunc it(string message, void delegate() func, string file, size_t line)

The message should describe what the test should do.

shouldBeGreater
void shouldBeGreater(T a, U b, string message, string file, size_t line)

Used to assert that one value is greater than another value.

shouldBeGreaterOrEqual
void shouldBeGreaterOrEqual(T a, U b, string message, string file, size_t line)

Used to assert that one value is greater or equal than another value.

shouldBeIn
void shouldBeIn(T value, U[] valid_values, string file, size_t line)

Used to assert that one value is in an array of specified values.

shouldBeLess
void shouldBeLess(T a, U b, string message, string file, size_t line)

Used to assert that one value is less than another value.

shouldBeLessOrEqual
void shouldBeLessOrEqual(T a, U b, string message, string file, size_t line)

Used to assert that one value is less or equal than another value.

shouldBeNull
void shouldBeNull(T a, string message, string file, size_t line)

Used to assert that one value is equal to null.

shouldEqual
void shouldEqual(T a, U b, string message, string file, size_t line)

Used to assert that one value is equal to another value.

shouldNotBeIn
void shouldNotBeIn(T value, U[] valid_values, string file, size_t line)

Used to assert that one value is NOT in an array of specified values.

shouldNotBeNull
void shouldNotBeNull(T a, string message, string file, size_t line)

Used to assert that one value is NOT equal to null.

shouldNotEqual
void shouldNotEqual(T a, U b, string message, string file, size_t line)

Used to assert that one value is NOT equal to another value.

shouldThrow
void shouldThrow(void delegate() cb, string file, size_t line)

Used for asserting that a delegate will throw an exception.

shouldThrow
void shouldThrow(string message, void delegate() cb, string file, size_t line)

Used for asserting that a delegate will throw an exception.

Examples

import BDD;

int add(int a, int b) {
	return a + b;
}

unittest {
	describe("math#add",
		before(delegate() {

		}),
		after(delegate() {

		}),
		it("Should add positive numbers", delegate() {
			add(5, 7).shouldEqual(12);
		}),
		it("Should add negative numbers", delegate() {
			add(5, -7).shouldEqual(-2);
		})
	);
}

Meta

Version

3.1.0

License

Boost Software License - Version 1.0