• Mark_Kaprielian
  • NEWBIE
  • 10 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello All
I'm new to Apex.  I have successfully created a Case Trigger and a Class which I call from it.   I have 100% coverage of my Class methods.   I now need to write test coverage for my Case Trigger code.  Classes and Methods seem straight forward to me as it's pure calls.  For the Case Trigger code, I need to do things to the system to have it invoke things.  This I do not know how to do despite trying to find examples.

I believe a simple example would help me understand the technique and in fact would be the solution I need for this my first attempt at Trigger testing.

My Case trigger is to designed to take action when the Case  Status field changes.
My trigger test needs to change the status to traverse the different actions that are taken based on the new status.
  1. Do I need to create a new case record for each test then change the status before I loose the scope of the test?
    • Note there are several required fields I would need to satisfy to create a new case record
  2. If yes to the above how can I push the creation of the record into a sub-class and then reference that case record while still in the scope of the test classes?

   Mark
 
Hello All
I'm new to Apex.  I have successfully created a Case Trigger and a Class which I call from it.   I have 100% coverage of my Class methods.   I now need to write test coverage for my Case Trigger code.  Classes and Methods seem straight forward to me as it's pure calls.  For the Case Trigger code, I need to do things to the system to have it invoke things.  This I do not know how to do despite trying to find examples.

I believe a simple example would help me understand the technique and in fact would be the solution I need for this my first attempt at Trigger testing.

My Case trigger is to designed to take action when the Case  Status field changes.
My trigger test needs to change the status to traverse the different actions that are taken based on the new status.
  1. Do I need to create a new case record for each test then change the status before I loose the scope of the test?
    • Note there are several required fields I would need to satisfy to create a new case record
  2. If yes to the above how can I push the creation of the record into a sub-class and then reference that case record while still in the scope of the test classes?

   Mark