fluent-asserts 0.6.0

Fluent assertions done right

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Build Status DUB Version DUB Installs Percentage of issues still open Average time to resolve an issue

Writing unit tests is easy with Dlang. The unittest block allows you to start writing tests and to be productive with no special setup.

Unfortunately the assert expresion does not help you to write expressive asserts, and in case of a failure it's hard to find why an assert failed. The fluent-asserts library allows you to more naturally specify the expected outcome of a TDD or BDD-style test.

To begin

  1. Add the DUB dependency: https://code.dlang.org/packages/fluent-asserts
  2. Import it:
import fluent.asserts;
  1. Use it:
    unittest {
        true.should.equal(false).beacause("this is a failing assert");

    unittest {
        Assert.equal(true, false, "this is a failing assert");
  1. Run the tests:
➜  dub test --compiler=ldc2


API Docs

The library provides the should template and the Assert struct.


should can be used in combination with Uniform Function Call Syntax (UFCS)

auto should(T)(lazy const T testData);

So the following statements are equivalent


In addition, the library provides the not and because modifiers that allow to improve your asserts.

not negates the assert condition:


because allows you to add a custom message:

    true.should.equal(false).because("of test reasons");
    ///will output this message: Because of test reasons, true should equal `false`.


Assert is a wrapper for the should struct that allows you to use the asserts with a different sintax.

For example, the folowing lines are equivalent:

    Assert.equal(testedValue, 42);

All the asserts that are available using the should syntax are available with Assert. If you want to negate the check, just add not before the assert name:

    Assert.notEqual(testedValue, 42);

You can use fluent asserts with:


MIT. See LICENSE for details.

  • Szabo Bogdan
Sub packages:
fluent-asserts:core, fluent-asserts:vibe
1.0.0 2022-Aug-24
1.0.0-beta.2 2022-Aug-24
1.0.0-beta.1 2022-Aug-12
0.14.0-alpha.13 2022-May-02
0.14.0-alpha.11 2021-Dec-16
Show all 63 versions
Download Stats:
  • 9 downloads today

  • 101 downloads this week

  • 266 downloads this month

  • 49129 downloads total

Short URL: