Starting with Spring 12 Apex test cases will not have access to org data

A good practice that Salesforce recommends is that Apex test cases create their own test data. They should not assume that certain data is present in the Salesforce instance. However this was not enforced. As an example a developer could create a test account, and then use it in her test case.

The problem with such an approach is that if the test data is deleted from either Sandbox or Production, then the test case will fail. Such failures in test cases can take time to investigate and resolve.

Thus a best practice that Salesforce recommends is that all Apex test cases should create their test data within the test case. This is “enforced” by default, starting with Spring 2012 (Api version 24). A test case will not be able to access pre-existing Salesforce data. It must create its own test data.

For existing test cases that use organization data, it may not be worth the effort to change them to not use organizational data. To support backward compatibility, Salesforce supports @isTest(SeeAllData=true) that can be put before an Apex test class. If SeeAllData is set to true, then Apex test cases will continue to have access to existing organization data as before. Example below illustrates this usage -

public class TestDataThatUsesExistingdata {
     static testmethod void TestMethodFromWinter12() {
     // Query an existing account in the organization.
     Account a = [SELECT Id, Name from account where name="test"];
     //Do something with account a