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
saikrishna.Gsaikrishna.G 

Not getting test coverage for the class created in Batchable class

Hi i have written a batch class for integration for that i have created the class in batchable class like this 
public class AccountsInsertBatch implements Database.Batchable<Account>,Database.AllowsCallouts{  
     public class accountt
         {
         public string entity_id;
         public string website_id;
         public string email;
         public string group_id;
         public string created_at;
         public string disable_auto_group_change;
         public string firstname;
         public string middlename;
         public string gender;
         public string Telephone;
         public string lastname;
         public string created_in;
         public string suffix;
         public string taxvat;
         public string ShippingAddress;  
         public string dob;      
         }
          public Iterable<Account> start(database.batchablecontext bc) {
 //Logic
     }
public void execute(database.BatchableContext BC, List<Account>accountquery){  
 //Logic
}
public void finish(Database.BatchableContext BC){ 
}
Am not getting the test coverage for the class which i have created in the Batch class.How to cover this class code covwerage?
my test class is
@isTest
public class AccountsInsertBatchTest implements HttpCalloutMock  {    
  public HTTPResponse respond(HTTPRequest req)
    { 
       HttpResponse res = new HttpResponse();
       res.setBody('{"4":{"entity_id":"4","website_id":"1","email":"ed@krishna.com","group_id":"1","created_at":"2013-09-17 14:17:12","disable_auto_group_change":"0","created_in":"Default Store View","prefix":null,"firstname":"test","middlename":null,"lastname":"Sea","suffix":"Mr.","taxvat":"123","dob":"2014-11-03 00:00:00","gender":"1"}}');
       res.setStatusCode(200);
       return res;   
    }
    @isTest static void testAccountInsert(){
        Test.StartTest();
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        MagentAccountsInsertBatch instance = new MagentAccountsInsertBatch ();
        database.executebatch(instance);        
        Test.StopTest();
        }
     @isTest static void testAccountInsert1(){
     Test.StartTest();
        insert new Account(LastName='krishna',personemail='ed@krishna.com',Entity_Id__c='1656');
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        MagentAccountsInsertBatch instance1 = new MagentAccountsInsertBatch ();
        database.executebatch(instance1); 
         Test.StopTest();    
}
}
sfdc550sfdc550
Hi saikrishna.garnepudi,

Run your class in developer console and check where the code coverage was lagging. It is easiest way. Unless all the code is shared no one answer where the test class code is not covered.
saikrishna.Gsaikrishna.G
am not getting test coverage for accountt class for remaning program am getting it 
Suneel#8Suneel#8
In the code you posted accountt is not being instantiated.I guess that is the reason for not being covered.You can instantiate this class and retry it
sfdc550sfdc550
Try to instantiate/initialize account
eg: account ac=new account();
     ac.name='test';

//perform insert operations
//intitialize some more values and try to check test class code coverage you test class code coverage will increases