How to achieve Test Coverage for Interface Classes

I am using the trigger framework presented here, which uses several interfaces and utility classes:

http://krishhari.wordpress.com/2013/07/22/an-architecture-framework-to-handle-triggers-in-the-force-com-platform/

And my question is the following: How does one achieve test coverage for Interfaces? Are these even factored in to test coverage?

Answer

The interface doesn’t need to be tested but any class that implements the interface will need test coverage

So ..

public interface IFoo {
   void doBar();
}

does not need to be test covered but the implementations do need coverage

public class MyClass implements IFoo {
  public void doBar() {
    // lines of code implementing doBar() method must be covered
 }
}

The trigger framework you mentioned requires you to provide implementations of the various trigger handlers. When you do DML in your testmethods, the triggers will execute and the handlers will then get coverage

Attribution
Source : Link , Question Author : atmdd , Answer Author : cropredy

Leave a Comment