I am creating a test class that will test my controller class which uses almost 5 to 8 objects that has many DML statements like insert and delete, however I am feeling a little bit worried about not getting the result like in my controller class. As a turnaround I used the SeeAllData=True annotation in order not to make sample data for each object and to cover most of my codes.

Question: When using the SeeAllData=True annotation, will it also do the DML statements in the actual record and reflect in the database?


@isTest SeeAllData=True
public with sharing class ControllerTest
    static testmethod void sampleTest()
     //Codes that will test the Controller using the data from the annotation

2 Answers 2


Test methods have a built-in "rollback" function that is implicitly called at the completion of every test. Not only will data created within the test method not persist, any changes that occur to "live" data will also not persist. This means that even with SeeAllData=true, you can never accidentally modify or delete "live" data, because it is guaranteed to be rolled back.

  • So it means that having the @isTest annotation it runs in different context and even there will be changes in the data using SeeAllData=true, it will only roll back after the execution of test right? Oct 23, 2014 at 6:24
  • Only the test method will see those changes, because an incomplete transaction is "isolated" from the rest of the database. This means that at no point will the changes made in the test method will be visible to any user.
    – sfdcfox
    Oct 23, 2014 at 13:14

Using the SeeAllData annotation will only give your test methods access to the existing data in your org. I don't think you should be using it, instead create each of the records that you need for your test cases inside your test method.

All the records that you insert in your test methods are only saved to the database within the test context and completely isolated from the original existing data in your org.

  • 2
    for clarity, deletes and updates are also wrapped up in the transaction and rolled back after the test Oct 23, 2014 at 2:42
  • 5
    Sometimes you need to use live data. Sometimes you can't help it. Use live data when you need to, and don't use it when you don't.
    – sfdcfox
    Oct 23, 2014 at 4:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .