8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutterで例外が起きるテストの書き方

Last updated at Posted at 2020-03-28

FlutterのUnitTestを書いていて、忘れそうなので、メモ。

1. MyException という例外が起きるはずのチェック

xxx_test.dart
expect(() => 例外が起きるはずの処理,
          throwsA(TypeMatcher<MyException>()));

2. 組み込みの例外/エラーが起きるはずのチェック

(1) FormatException

xxx_test.dart
expect(() => 例外が起きるはずの処理,
          throwsFormatException);

(2) ArgumentError

xxx_test.dart
expect(() => 例外が起きるはずの処理,
          throwsArgumentError);

参考

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?