BDD

Behavior Driven Development for the D programming language

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

Members

Functions

describe
void describe(string describe_message, TestPair pairs)

The message is usually the name of the thing being tested.

it
TestPair it(string message, void delegate() func)

The message should describe what the test should do.

printResults
int printResults()

Prints the results of all the tests. Returns 0 if all tests pass, or 1 if any fail.

shouldBeGreater
void shouldBeGreater(T a, U b, string message = null, string file = __FILE__, size_t line = __LINE__)

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

shouldBeGreaterOrEqual
void shouldBeGreaterOrEqual(T a, U b, string message = null, string file = __FILE__, size_t line = __LINE__)

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

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

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

shouldBeLess
void shouldBeLess(T a, U b, string message = null, string file = __FILE__, size_t line = __LINE__)

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

shouldBeLessOrEqual
void shouldBeLessOrEqual(T a, U b, string message = null, string file = __FILE__, size_t line = __LINE__)

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

shouldBeNull
void shouldBeNull(T a, string message = null, string file = __FILE__, size_t line = __LINE__)

Used to assert that one value is equal to null.

shouldEqual
void shouldEqual(T a, U b, string message = null, string file = __FILE__, size_t line = __LINE__)

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

shouldNotBeNull
void shouldNotBeNull(T a, string message = null, string file = __FILE__, size_t line = __LINE__)

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

shouldNotEqual
void shouldNotEqual(T a, U b, string message = null, string file = __FILE__, size_t line = __LINE__)

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

shouldThrow
void shouldThrow(void delegate() cb, string message = null, string file = __FILE__, size_t line = __LINE__)

Used for asserting that a delegate will throw an exception.

Examples

1 import BDD;
2 
3 int add(int a, int b) {
4 	return a + b;
5 }
6 
7 unittest {
8 	describe("math#add",
9 		it("Should add positive numbers", delegate() {
10 			add(5, 7).shouldEqual(12);
11 		}),
12 		it("Should add negative numbers", delegate() {
13 			add(5, -7).shouldEqual(-2);
14 		})
15 	);
16 }
17 
18 // Prints the results of the tests
19 int main() {
20 	return BDD.printResults();
21 }

Meta

Version

1.3.0

License

Boost Software License - Version 1.0