mercredi 2 mars 2016

Why can't we mock final classes in Mockito? [duplicate]

This question already has an answer here:

Recently while unit testing I got to know the limitation that I can't mock final classes. It feels weird because the class under test uses these final classes and these final classes are part of some external API.

Why this limitation exists and how to get around of this limitation?

  @Inject
  public RemoteClient(DfpSession dfpSession, DfpServices dfpServices) {
    this.dfpSession = dfpSession;
    this.dfpServices = dfpServices;
  }

above, DfpServices is a final class.

PS: I am using Guice to inject the final class in my class under test.

Aucun commentaire:

Enregistrer un commentaire