Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @isTest
- public class todaysBatchTests {
- public static testMethod void testTodaysProcess(){
- /***create test records***/
- String query = 'SELECT id, name, domainName__c, name FROM Account WHERE ((name = \'gmail.com\' AND domainName__c = \'gmail.com\') OR'+
- '(name = \'yahoo.com\' AND domainName__c = \'yahoo.com\') OR'+
- '(name = \'hotmail.com\' AND domainName__c = \'hotmail.com\'))';
- List<Account> dupeAccs = new List<Account>();
- List<Contact> testCons = new List<Contact>();
- List<Lead> testLeads = new List<Lead>();
- List<Case> testCs = new List<Case>();
- for(integer x=0;x<10;x++){
- Account yahoo = new Account(name = 'yahoo.com', email_adress__c = 'jimmy'+x+'@yahoo.com');
- Account gmail = new Account(name = 'gmail.com', email_adress__c = 'jimmy'+x+'@gmail.com');
- Account hotmail = new Account(name = 'hotmail.com', email_adress__c = 'jimmy'+x+'@hotmail.com');
- dupeAccs.add(yahoo);
- dupeAccs.add(hotmail);
- dupeAccs.add(gmail);
- }
- insert dupeAccs;
- for(Account acc : dupeAccs){
- For(integer x=0;x<20;x++){
- Account testAcc = datafactory.testAccount(x);
- insert testAcc;
- testCons.add(datafactory.testcontact(x, testacc.id));
- testLeads.add(datafactory.testLead(x,testacc.id));
- testCs.add(datafactory.testCase(x, testacc.id));
- }
- }
- insert testCons;
- insert testleads;
- insert testcs;
- Account masterG = new Account(name = 'super duper master gmail.com', email_adress__c = 'super@gmail.com');
- Account masterY = new Account(name = 'super duper master yahoo.com', email_adress__c = 'super@yahoo.com');
- Account masterH = new Account(name = 'super duper master hotmail.com',email_adress__c = 'super@hotmail.com');
- insert masterG;
- insert masterY;
- insert masterH;
- /***test records created***/
- //do our testing with a fresh set of limits
- test.startTest();
- //instantiate new batch class
- todaysBatchProcess tbp = new todaysBatchProcess(query);
- //execute batch process and store job id
- Id batchid = database.executeBatch(tbp,50);
- //spit out batchId to query job
- system.debug(batchId);
- test.stopTest();
- system.assertEquals('Success', [SELECT status FROM AsyncApexJob WHERE id = :batchId].status);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement