所有Apex类和触发器的平均测试覆盖率为0%,至少需要75%的测试覆盖率

时间:2011-02-02 07:44:15

标签: salesforce

这里我在开发人员版中有顶级类和visualfource页面,而我正在上传包我得到的错误如“所有Apex类和触发器的平均测试覆盖率为0%,至少需要75%的测试覆盖率”如果可能的话,请让我知道解决方案。

Apex class:
public virtual class SendEmailToFeedback
{ 
    public String items { get; set; }
    Opportunity opportunity;
    public String subject{ get; set; }
    public String body { get; set; }
    public String lid { get; set; }
    public String response {get; set;}
    List<Opportunity> Opp;


private static testMethod void myShareTest(){


}  


    public PageReference cancel() 
    {
        return null;

    }   
    public List<Opportunity> getOpp()
    {
       if(Opp== null)
         {
           lid = System.currentPageReference().getParameters().get('name');
           Opp= [Select o.Name,o.Email__c from Opportunity o where o.id =:lid];
         }
        return Opp;

    }
    public PageReference send() 
    {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String addresses;
        if (Opp[0].Email__c != null)
        {
            addresses = Opp[0].Email__c;

                if (Opp[0].Email__c != null)
                {
                    addresses += ':' + Opp[0].Email__C;
                    String[] toAddresses = addresses.split(':', 0);
                    email.setSenderDisplayName('THYLAKSOFT LLC');
                    email.setSubject(subject);
                    email.setToAddresses(toAddresses);
                    email.setPlainTextBody(body + 'Click The Followoing Link http://tefllife.com/studentfeedback.html');
                    try
                   {
                     Messaging.SendEmailResult [] resultMail= Messaging.sendEmail(new 

Messaging.SingleEmailMessage[] {email});
                     if(resultMail[0].isSuccess())       
                     response = 'ok sent!';
                      else
                      {
                         response = resultMail[0].getErrors().get(0).getMessage();
                      }
                    }
                    catch(System.EmailException ex)
                    {
                      response = ex.getMessage();
                    }   
                }

        }

        return null;
    }

}


Visualforce page:
<apex:page controller="SendEmailToFeedback" id="thePage">
<apex:page

1 个答案:

答案 0 :(得分:3)

在部署代码或将其打包为Force.com AppExchange之前,单元测试必须涵盖75%的Apex代码,并且所有这些测试必须成功完成。这有很好的记录:

您需要编写涵盖至少75%代码的测试方法,并且需要成功运行。就这么简单,我认为没有人会为你编写代码。