mardi 27 mars 2018

How to test if method that takes argument is throwing an exception in dart?

If I have

class ErrorThrower{
  void throwAnError(String argument){
    throw new Error();
  }
}

I want to test if throwAnError throws Exception, or more precisely an instance of Error

This is my code but it doesn't work

  test('', () {
    var errorThrower = new ErrorThrower();
    expect(errorThrower.throwAnError("string"), throwsException);
  });

Aucun commentaire:

Enregistrer un commentaire