+ Start a Discussion
BylithiumBylithium 

Test Class for Trigger

Hi..I have finished writting a trigger I need to write a test class

 

do i need to create a new apex class and write the test class or can i just write the test class in the trigger itself starting my code with @isTest

 

It was giving me an error when I am trying to start the test class where the trigger ended.

Best Answer chosen by Admin (Salesforce Developers) 
the_wolfthe_wolf

Hi bylithium,

 

you need to create a new Apex TestClass to test the trigger;

 

@isTest is only available on Apex Class, not in trigger

All Answers

the_wolfthe_wolf

Hi bylithium,

 

you need to create a new Apex TestClass to test the trigger;

 

@isTest is only available on Apex Class, not in trigger

This was selected as the best answer
Pradeep_NavatarPradeep_Navatar

Creating a new Apex class for testing is better. Refer Apex guide for more details.

jeffdonthemic2jeffdonthemic2

This blog post should help explain how to write bulk safe triggers and test them properly:

 

Writing Bulk Triggers for Salesforce.com

 

Jeff Douglas

Appirio, Inc.

http://blog.jeffdouglas.com

 

Author: The Salesforce Handbook

BylithiumBylithium

Thanks Guys !!