function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi Kumar 259Ravi Kumar 259 

how do u write a bulkify test class

Best Answer chosen by Ravi Kumar 259
Amit Chaudhary 8Amit Chaudhary 8
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help

All Answers

Amit Chaudhary 8Amit Chaudhary 8

Please use below test class to check bulkify Opportunity trigger code:-
@isTest
public class oppertunity_Test
{
       public static testmethod void testoppertunity()
       {
			List<Account> listacc = new List<Account>();
			Account acc1 = new Account(Name = 'TestAccountName');
			Insert acc1;
			List<Opportunity> listOpportunity  = new list<Opportunity >();
			for(Integer i = 0 ; i<=100 ;i++)
			{
				Opportunity opp1 = new Opportunity() ;
				opp1.Name ='Test'+i;
				opp1.accountid = acc1.id;
				opp1.StageName = 'Closed Won';
				opp1.CloseDate=Date.Today();
				listOpportunity.add(opp1);
			}         

			Test.startTest();
			insert listOpportunity;
			Test.stopTest();
       }
}

Some Link for you
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://blog.jeffdouglas.com/2009/04/20/writing-bulk-triggers-for-salesforce/
http://salesforce.stackexchange.com/questions/27676/test-class-not-covered-when-bulk-data-is-passed

Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
Ravi Kumar 259Ravi Kumar 259
Thanks Chowdary garu
Amit Chaudhary 8Amit Chaudhary 8
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
This was selected as the best answer