function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sam_matsam_mat 

Test Class code coverage problem

Hi,

 

public void search(){
        try{

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

                else if(searchstr=='0-9')
                    myString = OnTargetUtil.generateMystring(display('Target','Numeric'), OnTargetUtil.generateFieldList('TargetCentral'));
                else
                    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?

TerryLuschenTerryLuschen

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?