+ Start a Discussion

how Apex execution works?

Hi all, As we know that how trigger execution works but same thing i want to know how apex class execution works i.e. including test classes and when test classes fails.so kindly let me know asap Thanks!

Apex classes can be used in a number of ways.  A few are below:


(1) To hold re-usable code.  In this case the class will be instantiated by the code that needs it - e.g. a trigger. visualforce controller, scheduled apex

(2) As an extension/custom visualforce controller - in this case it will be automatically instantiated by the platform when a user lands on a visualforce page.

(3) As a schedulable item - in this case the platform instantiates the class and executes it according to a time schedule

(4) As a custom web service - handled by the platform again.


Test classes are executed when code is deployed to production or on demand by a user.   If test classes fail during a deployment then the deployment will be rolled back.  Otherwise it will be marked as a failure but there are no other effects.

Thanks, Is there any way to avoid test failuers in the code and any standards available for developing the test classes so that we can easily find the test failuers in the code?kindly let me know.

Developerforce is a good place to look for this kind of information.  This wiki page covers testing: