Last updated:
0 purchases
fluent assertions
The Fluent Assertions library written in Dart.
It uses Dart's Extension Functions to provide a fluent wrapper around test assertions.
Usage #
Basic Assertions
These assertions are available for all objects.
Equality
'Hello'.shouldBeEqualTo('Hello');
copied to clipboard
'Hello'.shouldNotBeEqualTo('Word');
copied to clipboard
Reference equality
final me = Person(name: 'Karol');
final someoneElse = Person(name: 'Karol');
me.shouldBe(me);
me.shouldNotBe(someoneElse);
copied to clipboard
Subtypes
const num numberOfGirlsIAttract = 0;
numberOfGirlsIAttract.shouldBeInstanceOf<int>();
numberOfGirlsIAttract.shouldNotBeInstanceOf<double>();
copied to clipboard
Nullability
const hello = 'Hello';
hello.shouldNotBeNull();
copied to clipboard
const hello = null;
hello.shouldBeNull();
copied to clipboard
Booleans
const hasChildren = true;
hasChildren.shouldBeTrue();
hasChildren.shouldNotBeFalse();
copied to clipboard
const hasChildren = false;
hasChildren.shouldBeFalse();
hasChildren.shouldNotBeTrue();
copied to clipboard
Numerical Assertions
2.shouldBeGreaterOrEqualTo(2);
copied to clipboard
2.shouldBeGreaterThan(1);
copied to clipboard
2.shouldBeLessOrEqualTo(2);
copied to clipboard
1.shouldBeLessThan(2);
copied to clipboard
1.shouldBePositive();
1.shouldNotBeNegative();
copied to clipboard
(-1).shouldBeNegative();
(-1).shouldNotBePositive();
copied to clipboard
0.shouldBeZero();
1.shouldNotBeZero();
copied to clipboard
0.999.shouldBeNear(1, delta: 0.01);
copied to clipboard
0.shouldNotBeInRange(lowerBound: 1, upperBound: 6);
1.shouldBeInRange(lowerBound: 1, upperBound: 6);
copied to clipboard
String Assertions
'Flutter'.shouldBeEqualToIgnoringCase('FLUTTER');
'Flutter'.shouldNotBeEqualToIgnoringCase('Xamarin');
copied to clipboard
'Flutter rules'.shouldStartWith('Flutter');
'Flutter rules'.shouldNotStartWith('Xamarin');
copied to clipboard
'Flutter rules'.shouldStartWithIgnoringCase('FLUTTER');
'Flutter rules'.shouldNotStartWithIgnoringCase('Xamarin');
copied to clipboard
'I love Flutter'.shouldEndWith('Flutter');
'I love Flutter'.shouldNotEndWith('Xamarin');
copied to clipboard
'I love Flutter'.shouldEndWithIgnoringCase('flutter');
'I love Flutter'.shouldNotEndWithIgnoringCase('xamarin');
copied to clipboard
'I love Flutter'.shouldContain('love');
'I love Flutter'.shouldNotContain('hate');
copied to clipboard
'I love Flutter'.shouldContainIgnoringCase('LOVE');
'I love Flutter'.shouldNotContainIgnoringCase('HATE');
copied to clipboard
'I love Flutter'.shouldContainAll(['Flutter', 'love']);
'I love Flutter'.shouldContainAllIgnoringCase(['flutter', 'love']);
copied to clipboard
'I love Flutter'.shouldContainAllInOrder(['love', 'Flutter']);
'I love Flutter'.shouldContainAllInOrderIgnoringCase(['Love', 'Flutter']);
copied to clipboard
'12345'.shouldMatch(r'\d');
'Hello'.shouldNotMatch(r'\d');
copied to clipboard
''.shouldBeEmpty()
'name'.shouldNotBeEmpty()
copied to clipboard
''.shouldBeNullOrEmpty()
'name'.shouldNotBeNullOrEmpty()
copied to clipboard
' '.shouldBeBlank()
'name'.shouldNotBeBlank()
copied to clipboard
' '.shouldBeNullOrBlank()
'name'.shouldNotBeNullOrBlank()
copied to clipboard
Collection Assertions
Features and bugs #
Please file feature requests and bugs at the issue tracker.
Author #
Karol Lisiewicz
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.