You need to sign in to do that
Don't have an account?
nandhini 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();
}
}
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();
}
}
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