+ Start a Discussion

Test Class code coverage problem



public void search(){

            if(tabName1 =='myTargets'){
                    myString = OnTargetUtil.generateMystring(display('Target','All'), OnTargetUtil.generateFieldList('TargetCentral'));

                else if(searchstr=='0-9')
                    myString = OnTargetUtil.generateMystring(display('Target','Numeric'), OnTargetUtil.generateFieldList('TargetCentral'));
                    myString = OnTargetUtil.generateMystring(display('Target','Alphabetical'), OnTargetUtil.generateFieldList('TargetCentral'));


When i run test class for above code,

I am getting wierd output.

Even though it shows code inside elseif and else is getting covered by highlighting it with blue,

but elseif and els are shown in red.

I tried using different indentations.

What could be the reason?


Is anybody else having this same problem?   I am having the exact same problem.  


If I run my test in Eclipse though the Force.com IDE I will get over 90% test coverage.  If I run my test through the Salesforce UI I get only 52% coverage.   I have comments, white space, else statements and else if statements showing up as being red ( Not covered ) even though they shouldn't be.  


I have upgraded both my Test Class and the class itself to be version 22.


Any ideas?