0
votes

I have this class :

class Repository extends IRepository {
  Repository(RRGraphQL client) : super(client: client);

  @override
  Future<GraphQLResponse<PasswordSendToken$Mutation>> getResetPasswordToken(String email) {
    return client.artemis!.execute(
      .....
      ),
    );
  }
}

I want to test that does getResetPasswordToken method call or not :

so this is my test:

class RepoMoc extends Mock implements Repository {}

void main() {

  Repository repo = RepoMoc();
  test("repo", (){
    verify(() => repo.getResetPasswordToken).called(1);
  });
}

But I got this error :

package:test_api                          fail
package:mocktail/src/mocktail.dart 519:7  _makeVerify.<fn>
test/common/repository_test.dart 18:11    main.<fn>

Used on a non-mocktail object
1

1 Answers

0
votes

Try switching this:

Repository repo = RepoMoc();

To one of these:

final repo = RepoMoc();
RepoMoc repo = RepoMoc();
IRepository repo = RepoMoc();