RecentlyViewed data leakage in unit tests

I have some code that queries RecentlyViewed and needed to be unit tested. I noticed a failure today because more records are turning up than expected.

It turns out that if you query RecentlyViewed in a unit test, even without seeAllData, you still get actual records back. Should this be considered a bug in Apex?

Answer

This has now been posted as a Known Issue. See here to click that it affects you:

https://success.salesforce.com/issues_view?title=recentlyviewed-object-contains-customer-data-during-test-execution&Id=a1p3A000000ATEI

Attribution
Source : Link , Question Author : Charles T , Answer Author : Charles T

Leave a Comment