You need to sign in to do that
Don't have an account?
VSK98
Createdby date becomes null in test class
Hi,
@isTest
private class sendReminderwgntoemployees_Test{
Static testmethod void sendReminderwgntoemployees_TestMethod(){
Date td = system.Today();
User u;
User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
System.runAs (thisUser) {
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
UserRole r = [SELECT Id FROM UserRole WHERE Name=' Admin'];
u = new User(alias = 'sindu1', email='sandvarma1@gmail.com',
emailencodingkey='UTF-8', lastname='Smith',
languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, userroleid = r.Id,
timezonesidkey='America/Chicago',
username='sandvarma1@gmail.com');
insert u;
}
recordtype rt=[select id from recordtype where DeveloperName = 'Employee'];
Contact con=WCT_UtilTestDataCreation.createEmployee(rt.id);
// con.CreatedDate = td;
insert con;
list<_Wage_Notice__c> lstwgn = new list<_Wage_Notice__c>();
_Wage_Notice__cwgn = new _Wage_Notice__c();
wgn._Related_To__c = con.id;
wgn.WTPAA_Status__c = 'sent';
lstwgn.add(wgn);
insert lstwgn;
system.debug('created by user' +lstwgn[0].createdby);
system.debug('size********' +lstwgn.size());
system.debug('value of the status' +lstwgn[0].WTPAA_Status__c);
system.assertEquals('sent', lstwgn[0].WTPAA_Status__c );
@isTest
private class sendReminderwgntoemployees_Test{
Static testmethod void sendReminderwgntoemployees_TestMethod(){
Date td = system.Today();
User u;
User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
System.runAs (thisUser) {
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
UserRole r = [SELECT Id FROM UserRole WHERE Name=' Admin'];
u = new User(alias = 'sindu1', email='sandvarma1@gmail.com',
emailencodingkey='UTF-8', lastname='Smith',
languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, userroleid = r.Id,
timezonesidkey='America/Chicago',
username='sandvarma1@gmail.com');
insert u;
}
recordtype rt=[select id from recordtype where DeveloperName = 'Employee'];
Contact con=WCT_UtilTestDataCreation.createEmployee(rt.id);
// con.CreatedDate = td;
insert con;
list<_Wage_Notice__c> lstwgn = new list<_Wage_Notice__c>();
_Wage_Notice__cwgn = new _Wage_Notice__c();
wgn._Related_To__c = con.id;
wgn.WTPAA_Status__c = 'sent';
lstwgn.add(wgn);
insert lstwgn;
system.debug('created by user' +lstwgn[0].createdby);
system.debug('size********' +lstwgn.size());
system.debug('value of the status' +lstwgn[0].WTPAA_Status__c);
system.assertEquals('sent', lstwgn[0].WTPAA_Status__c );
Could you tell us what is failing in this or what your problem is?
Many thanks
.
When i check this line system.debug('created by user' +lstwgn[0].createdby); in debug ............I have been getting null......
Based on the Createddate of Wagenotice record ..........i am quering in batch class............So my test class not covered the execute method due to no records met in queried in batch class
Thanks
Siv