You need to sign in to do that
Don't have an account?
Test Class implements Schedulable --- Urgent Help
I am trying to write a test class but i am getting only 0% coverage , need help to get this fixed .Help appreciated.
global
class Migrate_LocAssign_Class_Batch implements Schedulable
{
globalvoid execute(SchedulableContext sc)
{
MigrationDate__c MigDt =[SELECT Id,LastUpdateDate__c fromMigrationDate__cwhereNamelike'LocAssign%'orderby LastUpdateDate__c desc Limit 1];
DateTime Dt = MigDt.LastUpdateDate__c;
List<
Location_Assignment__c> location = [Select Id ,Account__c,Org_Unit__cfromLocation_Assignment__cwhere LastModifiedDate > :Dt];
//inset a new entry in the Custom Setting - MigrationDate
MigrationDate__c mg = newMigrationDate__c(Name='LocAssign'+ System.now(),LastUpdateDate__c=System.Today());
insert mg;
// Define connection id
Id networkId = ConnectionHelper.getConnectionId(
'Hartford Life GBD');
Set<Id> LASet = newSet<Id>();
Set<Id> AccSet = newSet<Id>();
List<
Location_Assignment__c> Assignment = new List<Location_Assignment__c>();
// only share records created in this org, do not add accounts received from another org.
for (Location_Assignment__c newLocAssgn : location )
{
if (newLocAssgn.Id != null )
{
LASet.add(newLocAssgn.Id);
AccSet.add(newLocAssgn.account__c);
Assignment.add(newLocAssgn);
}
}
if (LASet.size() > 0)
{
List<
PartnerNetworkRecordConnection> LAConnections = new List<PartnerNetworkRecordConnection>();
for (Location_Assignment__c newLA : Assignment)
{
if (LASet.contains(newLA.Id))
{
System.debug(
'AccountId'+newLA.account__c);
PartnerNetworkRecordConnection newConnection =
newPartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newLA.Id,
SendClosedTasks =
false,
SendOpenTasks =
false,
SendEmails =
false,
ParentRecordId = newLA.account__c);
//newLA.account__c);
LAConnections.add(newConnection);
}
}
if (LAConnections.size() > 0 )
{
database.
insert(LAConnections);
}
}
}
}
You are probably getting 0% coverage because your code (as pasted) lacks a test method.
Here is a sample test method for a scheduleable apex class: