1

I'm looking to implement some of the ideas presented by Andrew Fawcett and his Apex Enterprise Patterns. Basic idea is to employ the design patterns that he documents very well, but not his fflib repository as it conflicts with many of the implementations we already have in place.

My question relates to the Domain base class SObjectDomain.cls. I notice that with the base class he includes @IsTest methods. I assume per my understanding of APEX documentation that those methods would in fact count against the overall code count since they are in a functional class.

  • Is that correct?
  • Also will those test run during deployment if they're not in a @IsTest class?
  • Is this a good practice? I've always figured this was an anti-pattern
1
  • 1
    Didn't think Andy In The Cloud would like having his name spelled that way so I fixed that for you. :P
    – Adrian Larson
    Jan 12 '17 at 23:59
5

This was the "classic" way of including unit tests with your main class. In version 28.0, if memory serves me, this was no longer possible. Code that claims to be compatible with 28.0 or higher can not use @isTest on any method in the class, but may use @testVisible to expose private members and methods to unit tests that need to use them. This is an anti-pattern, as you've said, and Salesforce versioned this change to newer API versions that forced newer code to use separate unit test classes.

2

These fflib_xxxxx classes were all updated to V37.0 five(5) months ago (along with some bug fixes / enhancements)

see https://github.com/financialforcedev/fflib-apex-common/tree/master/fflib/src/classes

I'd reinstall if you are exploiting these

2
  • I was using his 2012 Apex Enterprise Patterns repo which was referenced throughout the articles. He now has moved his repo as you said but I was still curious about the approach since I will be referencing it for my own solution. Thanks for the heads up though Jan 13 '17 at 21:48
  • @Xtremefaith - The pull request that updated the version# and wrote the test classes was probably prompted by the fflib team and fflib community wanting to pass the straight face test given their seminal contribution :-)
    – cropredy
    Jan 14 '17 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.