apex-enterprise-patterns / fflib-apex-common

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

fflib_SObjectSelectorTest Error: 'Assertion Failed: Expected: 12345.67, Actual: 9117.25' #489

Open adayIvey opened 1 month ago

adayIvey commented 1 month ago

Describe the bug when I run the tests in 'fflib_SObjectSelectorTest Class' I get the following error.

System.AssertException: Assertion Failed: Expected: 12345.67, Actual: 9117.25 CODE LINE: system.assertEquals(12345.67,result[0].AnnualRevenue);

I think this has to do with our org being multi currency and there is a conversion being applied on all currency fields in the Account object

To Reproduce

Run test 'fflib_SObjectSelectorTest' from Developer Console in salesforce in a multi currency org

Expected behavior All tests in class 'fflib_SObjectSelectorTest' pass and can handle currency correctly

Version I just installed the latest version

adayIvey commented 1 month ago

Setting the CurrencyIsoCode = 'USD' when the account data is created in the test fixed the issue for me

List accountList = new List { new Account(Name='TestAccount2',AccountNumber='A2',AnnualRevenue=12345.67, CurrencyIsoCode = 'USD'), new Account(Name='TestAccount1',AccountNumber='A1',AnnualRevenue=76543.21, CurrencyIsoCode = 'USD') };

ImJohnMDaniel commented 1 month ago

Thanks for the update @adayIvey. Glad to hear that you were able to resolve your issue. Cheers!

adayIvey commented 1 month ago

While I did resolve my issue I think the test should be updated to include a currency code when creating Account Data

stohn777 commented 1 month ago

Sounds like a reasonable and simple test improvement that would shield users from a nuisance test failure.

stohn777 commented 1 month ago

Hi @adayIvey,
I'm having difficulty reproducing your issue. Would you, please, send me a screenshot of your Manage Currencies page so that I recreate that in a scratch org?

adayIvey commented 1 month ago

@. @.

From: John Storey @.> Sent: Wednesday, June 12, 2024 7:30 PM To: apex-enterprise-patterns/fflib-apex-common @.> Cc: Day, Andrew @.>; Mention @.> Subject: Re: [apex-enterprise-patterns/fflib-apex-common] fflib_SObjectSelectorTest Error: 'Assertion Failed: Expected: 12345.67, Actual: 9117.25' (Issue #489)

External email: Only click links and attachments from recognized senders. Contact IT if you are unsure.

Hi @adayIveyhttps://github.com/adayIvey, I'm having difficulty reproducing your issue. Would you, please, send me a screenshot of your Manage Currencies page so that I recreate that in a scratch org?

- Reply to this email directly, view it on GitHubhttps://github.com/apex-enterprise-patterns/fflib-apex-common/issues/489#issuecomment-2164061149, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADXEGU7JPBH5G5CDSUJPPE3ZHDKY3AVCNFSM6AAAAABJHD4AM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRUGA3DCMJUHE. You are receiving this because you were mentioned.Message ID: @.**@.>>

stohn777 commented 1 month ago

Hi again @adayIvey, For some reason, your reply came through unreadable. Here's what I see on the Github site. image

adayIvey commented 1 month ago
image




image
stohn777 commented 1 month ago

@adayIvey I created a scratch org from this project's multi-currency definition and configured as depicted above, yet all FFLIB tests complete and pass.

image

Are there other multicurrency configurations that might help me to reproduce the issue that you're seeing? It's obvious you're experiencing something; we just need to identify the culprit for reproducibility.

Thanks!

adayIvey commented 2 weeks ago

sorry for the late reply but tbh I am not sure what else I can say to help

but I did just try deploying into our production org from github and I get this error

`Status: Completed Deployment CompleteTest failure, method: fflib_SObjectSelectorTest.testQueryLocatorById -- System.AssertException: Assertion Failed: Expected: 12345.67, Actual: 9038.49 stack Class.fflib_SObjectSelectorTest.testQueryLocatorById: line 88, column 1

Test failure, method: fflib_SObjectSelectorTest.testSelectSObjectsById -- System.AssertException: Assertion Failed: Expected: 12345.67, Actual: 9038.49 stack Class.fflib_SObjectSelectorTest.testSelectSObjectsById: line 61, column 1

labels/CustomLabels.labels`

Screenshot 2024-06-26 143258

to get around this I want to try and deploy it manually from from a sandbox where I have updated the test that is causing me issues and I have tried using changesets or vscode and I get issues. Is there a specific way I need to deploy these files (I have already deployed the Apex Mocks classes)

stohn777 commented 2 weeks ago

@adayIvey I have all confidence that something is causing an incompatibility with FFLIB in your orgs, but I can't condone a presumptive fix without an ability to reproduce the error and attribute it to a shortcoming in FFLIB. Again, I'm happy to pursue this further with more information. With that said, I'll take your latest screenshot and further attempt to reproduce the issue, especially with the corporate currency being the Canadian Dollar.

Aye? 😁

adayIvey commented 2 weeks ago

thanks, if you have any ideas on additional info I can provide I will just ask

stohn777 commented 2 weeks ago

@adayIvey, If you're adept with scratch orgs, the best path would be determining the key configuration facet, from your SF environments, that causes that unit test to fail in one of this repo's multi-currency scratch orgs. Otherwise, further progress will likely be delayed pending my availability to experiment further.