You need to sign in to do that
Don't have an account?
Guru 91
Code Coverage for Batch class?
Hi,
need test class help
global class CDPForecastExtractBatch implements Database.Batchable<sObject> {
String query;
Forecast_Scenario__c forecastScenario;
global CDPForecastExtractBatch(Forecast_Scenario__c scenario) {
forecastScenario = scenario;
}
global Database.QueryLocator start(Database.BatchableContext BC) {
query = 'SELECT Id, Deal__c, Deal__r.Parent_Deal_Id__c, Deal__r.Stage__c, Deal__r.IsPlaceholder_Deal__c, Deal__r.IsInfrastructure_Deal__c, Deal__r.RecordType.Name, Deal__r.Is_Cloned_Deal__c, Deal__r.Is_Closed_Deal__c, Deal__r.Forecast_Scenario__c, ';
query += '(SELECT Id, CDP_Asset__c, Customer__c, Customer__r.Name,Customer__r.Account_Subtype__c FROM CDP_Asset_Customer_Accounts__r) , ';
query += '(SELECT Id, Development_Deal_Id__c, Land_Name__c, CDP_Asset__c, Land_Area__c, Land_Area_UOM__c, Land_Source__c, Land_Code__c FROM CDP_Land_Strategy__r) ';
query += 'FROM CDP_Asset__c WHERE (NOT Deal__r.Stage__c like \'%Lost%\') AND (Deal__r.Is_Cloned_Deal__c = true OR (Deal__r.Stage__c like \'%Won%\') ) ';
query += 'AND Deal__r.Hold__c = false AND (Deal__r.IsNamedDeal__c = true OR Deal__r.IsPlaceholder_Deal__c = true OR Deal__r.IsInfrastructure_Deal__c = true OR (Deal__r.Stage__c like \'%Won%\') ) ';
query += 'AND Deal__r.RecordType.Name NOT IN ('+ '\'Value-Add\'' +')';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
CDPForecastExtractHandler.getChildRecords(scope, forecastScenario);
}
global void finish(Database.BatchableContext BC) {
}
}
need test class help
global class CDPForecastExtractBatch implements Database.Batchable<sObject> {
String query;
Forecast_Scenario__c forecastScenario;
global CDPForecastExtractBatch(Forecast_Scenario__c scenario) {
forecastScenario = scenario;
}
global Database.QueryLocator start(Database.BatchableContext BC) {
query = 'SELECT Id, Deal__c, Deal__r.Parent_Deal_Id__c, Deal__r.Stage__c, Deal__r.IsPlaceholder_Deal__c, Deal__r.IsInfrastructure_Deal__c, Deal__r.RecordType.Name, Deal__r.Is_Cloned_Deal__c, Deal__r.Is_Closed_Deal__c, Deal__r.Forecast_Scenario__c, ';
query += '(SELECT Id, CDP_Asset__c, Customer__c, Customer__r.Name,Customer__r.Account_Subtype__c FROM CDP_Asset_Customer_Accounts__r) , ';
query += '(SELECT Id, Development_Deal_Id__c, Land_Name__c, CDP_Asset__c, Land_Area__c, Land_Area_UOM__c, Land_Source__c, Land_Code__c FROM CDP_Land_Strategy__r) ';
query += 'FROM CDP_Asset__c WHERE (NOT Deal__r.Stage__c like \'%Lost%\') AND (Deal__r.Is_Cloned_Deal__c = true OR (Deal__r.Stage__c like \'%Won%\') ) ';
query += 'AND Deal__r.Hold__c = false AND (Deal__r.IsNamedDeal__c = true OR Deal__r.IsPlaceholder_Deal__c = true OR Deal__r.IsInfrastructure_Deal__c = true OR (Deal__r.Stage__c like \'%Won%\') ) ';
query += 'AND Deal__r.RecordType.Name NOT IN ('+ '\'Value-Add\'' +')';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
CDPForecastExtractHandler.getChildRecords(scope, forecastScenario);
}
global void finish(Database.BatchableContext BC) {
}
}
Raj Vakati
Try this