[![enter image description here](https://i.stack.imgur.com/LT6DZ.png)](https://i.stack.imgur.com/LT6DZ.png)Don't know why i am facing this issues in my test class to cover up the coverage with 75 %.

I am getting only 18 % code coverage. 

Class : 

```
global class SendPurchaseOrdrService{
    webService static String sendMail(String orderID) {
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
        try{
            Map<String,Purchase_Order_Email_Receiver__c> emailsetting = Purchase_Order_Email_Receiver__c.getAll();
            List<Purchase_Order__c> orderlst = [Select id,Opportunity__r.Accountid,Opportunity__r.Account.Name,Total_Amount__c,CurrencyIsoCode,Name,Type__c,Purchase_Order_Email_Sent__c from Purchase_Order__c where id =: orderID];
            String emailAddress = orderlst.size()>0 ? emailsetting.get(orderlst[0].Type__c).Email__c : null;
            if(emailAddress != null && emailAddress.length()>0){ 
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();        
                Pagereference pg = Page.PrintPurchaseOrder;
                pg.getParameters().put('id', orderID);
                Blob fileBody = Test.isRunningTest() ? Blob.valueOf('test') : pg.getcontentasPDF();

                Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
                attachment.setBody(fileBody);                
                attachment.setFileName('Purchase_Order.pdf');               
                mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );  

                mail.setToAddresses(new List<String>{emailAddress});

                mail.setSubject('The Shaker Kitchen Company Purchase Order');

                String body = 'Dear Sir / Madam, <br/><br/>';
                body += 'Our Purchase Order for your products is attached, please acknowledge receipt of this order via return email and quote the PO number on all invoices and correspondance.<br/><br/>';
                body += 'If you have any queries, please call 01285 238070 or email finance@theshakerkitchencompany.com <br/><br/>';
                body += 'Kind regards, <br/><br/>';
                body += 'The Shaker Kitchen Company <br/><br/>';
                mail.setHtmlBody(body);
                mails.add(mail);
            }           

            if(mails.size()>0){
                Messaging.sendEmail(mails);
            }

            Task task = new Task();
            task.Customer_Name__c = orderlst.get(0).Opportunity__r.Accountid;
            task.Total_Amount__c= orderlst.get(0).Total_Amount__c;
            task.WhatId = orderlst.get(0).Opportunity__c;
            task.Opportunity__c = orderlst.get(0).Opportunity__c;
            task.ActivityDate = system.today();
            task.Subject = orderlst.get(0).Name;
            task.Status = 'Completed';
            task.Priority ='Normal';
            task.CurrencyIsoCode = orderlst.get(0).CurrencyIsoCode;
            insert task;

            for(Purchase_Order__c purOrder : orderlst){
                purOrder.Purchase_Order_Email_Sent__c = true;
            }
            system.debug('@@orderlst : '+ orderlst);
            update orderlst;
            return 'send'; 
        }catch(Exception ex){
            System.debug('ex==>'+ex.getmessage());
            return ex.getmessage();
        }
     return null;
   }  
}

```

Test Class : 

```
@isTest
public class SendPurchaseOrdrServiceTest{
    static testMethod void MyTest(){
        Account a = new Account();
        a.Name = 'test';
        a.Email__c = 'test@test.com';
        a.CurrencyIsoCode = 'EUR';
        a.Phone = '789642';
        a.BillingCity= 'bhuj';
        a.BillingPostalCode = '370001';
        a.BillingCountry = 'india';
        a.BillingLatitude = 57.5 ;
        a.BillingLongitude = 67.7;
        a.BillingState = 'Gujarat';
        a.BillingStreet = 'Main';
        insert a;

        Opportunity opp = new Opportunity();
        opp.Name = 'Test Opportunity';
        opp.StageName = 'Stage 0';
        opp.CloseDate = system.today().addDays(10);
        opp.Accountid = a.id;
        opp.CurrencyIsoCode = 'GBP';
        insert opp;

        Purchase_Order__c po = new Purchase_Order__c();
        po.Name = 'test';
        po.Opportunity__c = opp.id;
        po.CurrencyIsoCode = 'GBP';
        po.Purchase_Order_Email_Sent__c = true;
        po.Type__c = 'NEFF';
        insert po;

        Blob b = Blob.valueOf('Test Data');  
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName( quote.Name + '.pdf');
        efa.setBody(b); 

        Attachment attachment = new Attachment();  
        attachment.ParentId = a.id;  
        attachment.Name = 'Test Attachment for Parent';  
        attachment.Body = b;  
        insert(attachment);

        List<Attachment> attachments = [select id, name from Attachment where parent.id=: a.Id];
        System.assertEquals(1, attachments.size());

        Task task = new Task();
        task.Customer_Name__c = a.id;
        task.Total_Amount__c = 12000;
        task.WhatId = opp.id;
        task.Opportunity__c = opp.id;
        task.ActivityDate = system.today();
        task.Subject = 'Invoice ';
        task.CurrencyIsoCode = 'GBP';
        task.Status = 'Completed';
        task.Priority ='Normal';
        insert task;

        Apexpages.currentPage().getParameters().put('id',po.Id);
        SendPurchaseOrdrService.sendMail(po.id);
    }
}

```