Open windybranch opened 3 weeks ago
Basic tests:
test('string should be null', () {
const String? str = null;
str.should.beNull();
});
test('string should not be null', () {
const String str = 'some string';
str.should.not.beNull();
});
In your example, you don't add brackets. Please remember that all assertions should end with methods.
You're right! My mistake on that example. It seems I need a more complicated one to illustrate the actual issue I'm having:
class Foo {
final String id;
Foo(this.id);
}
class Bar {
Foo? foo;
}
test("foo id should be null", () {
final bar = Bar();
bar.foo?.id.should.not.beNull(); // passes
expect(bar.foo?.id, isNotNull); // fails
bar.foo?.id.should.be("id"); // passes as well
});
With a basic example:
This test passes, whereas a normal
expect(str, isNotNull)
will fail correctly.