Skip to content

dart の test の matcher

error の確認


test('error: throws SampleError.', () {
    final base = Sample();
    final result = () => base.something();
    final actual = result;
    final expected = throwsA(TypeMatcher<SampleError>());
    expect(actual, expected);
});

type の確認


test('expected: return Sample.', () {
    final base = Sample();
    final result = base.something();
    final actual = result.wrapped;
    final expected = isA<Sample>();
    expect(actual, expected);
});