• jstelling
  • NEWBIE
  • 5 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

I have built a trigger on an object that updates fields on a related object.  This related object has many validation rules in place that are causing issues in building test data in my test class for this trigger.  My current approach is to create the needed test data in the correct manner to allow the validation rules to pass.  However, this means that if these rules change in the future, the test class might likewise also need to be updated.  In an effort to produce development that is low-maintainence in nature, flexible, and adaptable to changes, I would prefer to not use this approach.

 

Does anyone have any best practices or guidance on ways to write APEX tests that would remove the dependence on the validation rules?  The way I see it, the validation rules shouldn't cause my APEX tests to fail, as they would not indicate any defects in the APEX code itself, but the test data being generated.  Therefore, should we exclude these rules and leave the testing of them to System or Functional User testing?

 

The only solution I have come up with so far is to create a hidden "isTest" checkbox on the object with the validation rules.  This check box would be used in the rules to exclude records having this flag True.  This flag would only get set by my test class, and therefor circumvent the rules.  I'm sure there is some flaw in this approach that I am not thinking of, but am not sure.

 

 

I am wondering if i might be possible to reference and embedded an Excel spreadsheet within a VF page?  I think this was previously possible through the use of an s-control, but I'm not sure if/how it might be done with VF.

I have built a trigger on an object that updates fields on a related object.  This related object has many validation rules in place that are causing issues in building test data in my test class for this trigger.  My current approach is to create the needed test data in the correct manner to allow the validation rules to pass.  However, this means that if these rules change in the future, the test class might likewise also need to be updated.  In an effort to produce development that is low-maintainence in nature, flexible, and adaptable to changes, I would prefer to not use this approach.

 

Does anyone have any best practices or guidance on ways to write APEX tests that would remove the dependence on the validation rules?  The way I see it, the validation rules shouldn't cause my APEX tests to fail, as they would not indicate any defects in the APEX code itself, but the test data being generated.  Therefore, should we exclude these rules and leave the testing of them to System or Functional User testing?

 

The only solution I have come up with so far is to create a hidden "isTest" checkbox on the object with the validation rules.  This check box would be used in the rules to exclude records having this flag True.  This flag would only get set by my test class, and therefor circumvent the rules.  I'm sure there is some flaw in this approach that I am not thinking of, but am not sure.