Flutter: Test that a specific exception is thrown

后端 未结 4 431
攒了一身酷
攒了一身酷 2021-01-07 23:07

in short, throwsA(anything) does not suffice for me while unit testing in dart. How to I test for a specific error message or type?

Her

4条回答
  •  走了就别回头了
    2021-01-07 23:59

    After `TypeMatcher<>' has been deprecated in Flutter 1.12.1 I found this to work:

    expect(() => operations.lookupOrderDetails(), throwsA(isInstanceOf()));
    

提交回复
热议问题