Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a test class that is basically covering a class which has structure like

  public class classA {
    public class classB implements Triggers.Handler {
       public void handle(){
         ---some code----
    }
  }
  }

I have a trigger on object, something like

 trigger someTrigger on someObject(before insert, before update) {

new Triggers()

    .bind(Triggers.Evt.beforeInsert, new classA.classB())        

    .manage();
 }

I am inserting someObject in the test class and I also see its going into the ClassB in debug logs, but the code coverage for classA is showing as 0%. I have no idea what the issue is. Any thoughts or help??

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

There is a known issue http://success.salesforce.com/issues_view?id=a1p30000000Rle5AAC that was apparently fixed in Summer '12 but looks like there was a regression.

I ran into this problem before and was able to workaround it by creating an instance of the Outer class in the test.

@isTest
private class TestClassA {
  static {
    // This should get code coverage on inner class
    new ClassA();
  }

  @isTest static void testSomethingInClassB() {
    ClassA.ClassB b = new ClassA.ClassB();
    b.handle();
  }
}
share|improve this answer
    
Awesome. Thanks for the direction and solution. I am now able to get the coverage for the class –  logontokartik Jan 28 '13 at 11:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.