Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required
here i have apex class and visualfource page in developer开发者_开发百科 edition, while i am uploading package i am getting error like"Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required"so kindly let me know the solution if possible define code.
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
Before you can deploy your code or package it for the Force.com AppExchange, 75% of your Apex code must be covered by unit tests, and all of those tests must complete successfully. This is well documented:
- Documentation on testing Apex
- Wiki article on Apex Test Methods
- Presentation: Apex Test Coverage Best Practices
You need to write test methods that cover at least 75% of your code and they need to run successfully. It's as simple as that, and I don't think anyone is going to write your code for you.
精彩评论