apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
913 stars 518 forks source link

Test failures in environment with Financial Force packages installed #20

Closed adtennant closed 9 years ago

adtennant commented 10 years ago

When deploying into a fresh developer edition, all tests pass and everything is hunky dory.

When deploying into an environment which has the followingFinancial Force packages installed (and no other Apex), SObjectSelectorTests fail.

Class fflib_SObjectSelectorTest Method Name testDefaultConfig Pass/Fail Fail Error Message System.AssertException: Assertion Failed: Expected: AccountNumber,AnnualRevenue,Id,Name, Actual: Name,AnnualRevenue,AccountNumber,Id Stack Trace Class.fflib_SObjectSelectorTest.testDefaultConfig: line 185, column 1

Class fflib_SObjectSelectorTest Method Name testGetFieldListString Pass/Fail Fail Error Message System.AssertException: Assertion Failed: Expected: myprefix.AccountNumber,myprefix.AnnualRevenue,myprefix.Id,myprefix.Name, Actual: myprefix.AccountNumber,myprefix.Name,myprefix.Id,myprefix.AnnualRevenue Stack Trace Class.fflib_SObjectSelectorTest.testGetFieldListString: line 46, column 1

adtennant commented 10 years ago

PS. I wish these were global in c2g so I didn't have to have the same classes twice.

adtennant commented 10 years ago

I've not yet figured out why the above pull request resolves this issue, but it does. If I figure it out I will comment here.

afawcett commented 10 years ago

Yeah, i think as i've said in another comment, talking with @capeterson i think the use of fflib_QueryFactory in the new Selector base class is causing some instability in the tests, since QueryFactory is using Set's / Map's. We need to put some ordering into the fields emitted when the toSQL function is called.

capeterson commented 10 years ago

I have an open pull request on our internal git with a fix to make fflib_QueryFactory.toSOQL() deterministic. Once it makes it through code review we'll get it updated here.

capeterson commented 10 years ago

30 should take care of this, although we might have to update the selector tests after it's applied since the deterministic ordering might be different than the previous ordering that happened to be dependent on how salesforce felt (feels?) like implementing the Set collection internally.

rsoesemann commented 9 years ago

Any updates on this? We really want to use the fflib packages but this makes them a risk for every release.

tfuda commented 9 years ago

I believe I have fixed this in pull request #33. Because the field collection is backed by a Set, the are returned in an unpredictable order. Since I don't believe there's any particular need to preserve the ordering of the fields in the generated SOQL, I fixed the test assertions to tolerate the fields coming back in any order.

afawcett commented 9 years ago

I've now merged PR 33, thanks.