如何在salesforce中上传包

时间:2011-01-27 06:40:13

标签: salesforce

嗨,这是Ashwaq 我有一个顶级类和顶点页面,这两件事我必须上传到包,而我上传这个包我得到这个错误“没有在包的选定的Apex代码中找到testMethods”。所以请让我知道这个解决方案并给我回复asp。

apex class:

public global 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;
    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;
    }

}

顶点是:

<apex:page controller="SendEmailToFeedback" id="thePage">
<script>
function confirmCancel() {
var isCancel = confirm("Are you sure you wish to cancel?");
if (isCancel) return true;
return false;
}
</script>
 <apex:form >
    <apex:pageBlock >

        <p>Fill out the fields below to test how you might send an email to a Opportunity.</p><br />
        <apex:dataTable value="{!Opp}" var="o" border="1">
            <apex:column >
                <apex:facet name="header">Name</apex:facet>
                {!o.Name}
            </apex:column>
            <apex:column >
                <apex:facet name="header">Email</apex:facet>
                 {!o.Email__c}
            </apex:column>
        </apex:dataTable>
        <br /><br />
        <apex:outputLabel value="Subject" for="Subject"/>:<br />
        <apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
        <br /><br />
        <apex:outputLabel value="Body" for="Body"/>:<br />
        <apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/>
        <br /><br /><br />
        <apex:commandButton value="SendEmail" action="{!send}"/> 
        <apex:commandButton action="{!cancel}" value="Cancel"
        onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlock>
     </apex:form>
</apex:page>

1 个答案:

答案 0 :(得分:3)

您可以在没有单元测试的情况下将Apex代码部署到沙箱,但是部署到生产实例需要您为Apex代码编写单元测试。

更多信息here

此外,部署到生产中需要至少75%的单元测试代码覆盖率。