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
nandhini vasudevannandhini vasudevan 

how to do negative and bulk test?

Hi
can anyone tell me how to write a negative and bulk test class for my below code?

@isTest 
public class caseTriggerHandlerTest 
{
    static testMethod void setup() 
    {
              
       Account MyAccount = new Account();
        MyAccount.Name='Test Account';
        insert MyAccount;
        
        Contact MyContact = new Contact();
        MyContact.Lastname ='Test contact';
        MyContact.AccountId = MyAccount.Id;
        insert MyContact; 
      
        Case caseObj = new Case();
        caseObj.AccountId = Myaccount.Id;
        caseObj.Status = 'New';
        caseObj.Country__c = 'Chile'; 
        insert caseObj;
    Test.StartTest(); //to refresh the governor limits
        
        caseObj.Status = 'Closed';
    
        Test.StopTest();
           }
}
SwethaSwetha (Salesforce Developers) 
HI Nandhini,
The below trailhead should help you get started with negative tests 
https://trailhead.salesforce.com/en/content/learn/modules/unit-testing-on-the-lightning-platform/negative-tests
https://developer.salesforce.com/forums/?id=906F0000000BSo5IAG

Has an example of bulk test https://trailhead.salesforce.com/content/learn/modules/apex_testing/apex_testing_data

https://www.forcetalks.com/blog/salesforce-apex-test-class-best-practices/#

If this information helps, please mark the answer as best.Thank you