Description

Fluent assertions done right

Package Information

Version0.4.1 (2017-Apr-30)
Homepage http://fluentasserts.szabobogdan.com/
Repository https://github.com/gedaiu/fluent-asserts
LicenseMIT
CopyrightCopyright © 2017, Szabo Bogdan
AuthorsSzabo Bogdan
Registered bySzabo Bogdan
Sub packages
fluent-asserts:core
fluent-asserts:vibe
Dependencies

fluent-asserts:core

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

Fluent Asserts

Build Status DUB Version DUB Installs

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-assert 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);
    }
  1. Run the tests:
➜  dub test --compiler=ldc2

asciicast

API Docs

The library uses the should template in combination with Uniform Function Call Syntax (UFCS)

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

So the following statements are equivalent

exepectedValue.should.equal(42);
should(expectedValue).equal(42);

In addition, the library provides a not modifier that negates the assert condition:

exepectedValue.should.not.equal(42);

You can use fluent asserts with:

License

MIT. See LICENSE for details.

Available versions

0.4.1 0.4.0 0.3.0 0.2.0 ~master