expector

Last updated:

0 purchases

expector Image
expector Images
Add to Cart

Description:

expector

Expector #

This package provides a way to write tests more easily in a fluent
manner (with content assists).
Instead of writing expect(value, and provide a matcher to check the value,
just type expectThat(value). and let the content assist do its job!
Usage #
A simple usage example:
import 'package:expector/expector.dart';
import 'package:test/test.dart';

String? f() => 'hello';

void main() {
test('f() returns a 5-length string', () {
expectThat(f()).isNotNull
..isNotEmpty
..hasLength(5);
});
}
copied to clipboard
What's the problem with test package ? #
The test package allows users to describe
expectations with matchers: expect(value, matcher). Unfortunatelly there are
a lot of matchers and it's easy to use a matcher that has no meaning regarding
the value tested. In this case, there will be no error at compile time but there
will be a runtime error. For instance:
import 'package:test/test.dart';

String? f() => 'hello';

void main() {
test('f() returns a 5-length string', () {
expect(f(), isNotNull);
expect(f(), isNotEmpty);
expect(f(), hasLength(5));
expect(f(), isNaN); // no compile time
});
}
copied to clipboard
Another issue is that there is no content assist to help user. Everything is
suitable as matcher and it could be hard to find the good one.
License #
Apache 2.0

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.