I have a Batch Class
global class UpdateAssetInstallStatus implements Database.Batchable<sObject> {
global Integer assetsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator([SELECT Name,InstallDate FROM Asset WHERE InstallDate <= TODAY]);
}
global void execute(Database.BatchableContext bc, List<Asset> scope){
// process each batch of records
for (Asset asset : scope) {
asset.Status = 'Installed';
assetsProcessed = assetsProcessed + 1;
}
update scope;
}
global void finish(Database.BatchableContext bc) {
System.debug(assetsProcessed + ' records processed.');
}
}
that is triggered by a Scheduled Class (through
global class ScheduleUpdateAssetInstallStatus implements Schedulable {
// Run daily at 10AM
public static String CRON_EXP = '0 0 10 * * ? *';
global static String scheduleAssetUpdate() {
ScheduleUpdateAssetInstallStatus sc = new ScheduleUpdateAssetInstallStatus();
return System.schedule('Asset Install Status Update', CRON_EXP, sc);
}
global void execute(SchedulableContext ctx) {
UpdateAssetInstallStatus batchJob = new UpdateAssetInstallStatus();
Database.executeBatch(batchJob);
}
}
Is it necessary to write two separate test classes for these or is it possible to do it in one? Is it recommended to do two separate ones? To achieve 100% code coverage I have to insert the same dummy data in both, rather than just the Batch Class.