I have come across this error in production but in a test class where I am defining 5 rows only , how come I'm facing this error ? Also there was no error in QA but error in Dev and Prod.

List<Object__c> objList = new List<Object__c>();
    Object__c obj = new Object__c(Delivery_Location__c='Dalian',Ref__c = '13',Volume__c=1, Grad_Volume__c=1,Month__c='January',Year__c='2013',Country__c='ANZ');
insert objList;

Should I remove @isTest(seeAllData=true) ?

Please suggest.

  • Btw: even in tests it's not good to query non selective, it's good to be sure you'll get the records that you want to get. OR validate that you do. Commented Mar 23, 2015 at 11:01
  • Besides using seeAllData annotation - are you sure that you insert correct list? In your snippet we can see that you create a new list and then insert another one...
    – neff
    Commented Mar 23, 2015 at 11:01
  • @neff That was an error in the snippet only . Corrected. Commented Mar 23, 2015 at 11:04
  • and can you show/tell us what is done in triggers of Object__c? Looks like there might be something wrong over there because otherwise single element collection insert shouldn't cause such error. It might be a general issue and not test class only
    – neff
    Commented Mar 23, 2015 at 11:20

2 Answers 2


Yes you should remove seeAllData=true and never use it again (Isolation of Test Data in Unit Tests). Instead create a test data directly in your test class and work only with that data. You have to assume that there is no data you can access in the production org.

Common Test Utility Classes for Test Data Creation.

In addition your code should respect system limits. Use Limits Class to access limits dynamically in apex.


The @isTest(seeAllData=true) annotation is most likely the cause of this issue. With the annotation the test is seeing all data in your org. Production may have a lot more records in it than other environments which is why you weren't seeing it everywhere.

Your tests should not rely on data that may/may not exist in the org.

You must log in to answer this question.

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