fluent-asserts
Write readable, expressive tests in D with a fluent API. Current version v2.0.0-beta.5
From This
assert(user.age > 18);// Assertion failure: false is not trueTo This
expect(user.age).to.be.greaterThan(18);// ASSERTION FAILED: expect(user.age) should be greater than 18// ACTUAL: 16// EXPECTED: greater than 18The difference is clarity. When tests fail at 2am, you need to understand why immediately. fluent-asserts gives you assertions that read like sentences and error messages that tell you exactly what went wrong.
The Fluent Chain
Every assertion flows naturally from value to expectation:
expect(response.status) // what you're testing .to.be // optional readability .greaterOrEqualTo(200);// the assertionThe language chains (.to, .be) improve readability—they exist purely so your tests read like documentation.
Beyond Values
Test behavior, not just data:
// Memory allocationexpect({ auto arr = new int[1000]; }) .to.allocateGCMemory();
// Exceptionsexpect({ parseConfig("invalid"); }) .to.throwException!ConfigError .withMessage("Invalid syntax");
// Execution timeexpect({ complexCalculation(); }) .to.haveExecutionTime .lessThan(100.msecs);Quick Example
import fluent.asserts;
unittest { expect("hello").to.equal("hello"); expect(42).to.be.greaterThan(10); expect([1, 2, 3]).to.contain(2); expect(10).to.not.equal(20);}