Salesforce Test accesses some org records

I’m bit new to SF.

I have problem with one of the tests. Basically I create an empty test and check if records are empty. But whatever I do, ContentNote records are not 0. When debugging, I saw that those two ContentNote records are from my development org.
My question is that why are they accessible in my test, even though I’m not using SeeAllData=true.

Assertion error I’m getting:
System.AssertException: Assertion Failed: Expected: 0, Actual: 2

Here is my sample test:

private class SomeServiceTest {
    private static void createData() {


private static testMethod void testSomething() {
        System.assertEquals(0, [select Id from ContentNote].size());


                                  **A possible bug**


Isolation of Test Data from Organization Data in Unit Tests

Starting with Apex code saved using Salesforce API version 24.0 and
later, test methods don’t have access by default to pre-existing data
in the organization, such as standard objects, custom objects, and
custom settings data, and can only access data that they create.
However, objects that are used to manage your organization or metadata
objects can still be accessed in your tests such as:

  • User Profile
  • Organization
  • AsyncApexJob
  • CronTrigger
  • RecordType
  • ApexClass
  • ApexTrigger
  • ApexComponent
  • ApexPage


Test code saved using Salesforce API version 23.0 or earlier continues to have access to all data in the organization and its data access is unchanged.

What I found is:-

I have checked the same with latest API Version and got the same problem. Also, ContentNote does not fall under any of the above listed. Also, ContentNote Object records are not organization metadata.

I would like to get verify this by others too.

Source : Link , Question Author : Jaak , Answer Author : sanket kumar

Leave a Comment