lundi 1 octobre 2018

Flutter: testing

I was trying to test this function

  UserApi createUserApi(String url, String username, String password) {
    UserApi userApi = new UserApi(base: route(url), serializers: repo);
    userApi.base.basicAuth('$username', '$password');
    return userApi;
  }

basically, the test was to compare the result of this function with a "manually composition" of it, expecting to have the same result. But It doesn't:

  String username = "asd";
  String password = "asd";
  UserApi userApiTest = new UserApi(base: route("asd"), serializers: repo);
  userApiTest.base.basicAuth('$username', '$password');
  test("UserApi creation", () {
    UserApi userApi = _presenter.createUserApi("asd", "asd", "asd");
    expect(userApi, userApiTest);
  }); 

The result is always :

Expected: <Instance of 'UserApi'>
  Actual: <Instance of 'UserApi'>

Why are they different? In the debug every property is the same.

Aucun commentaire:

Enregistrer un commentaire