This post is very old but it is long overdue. Have you seen the Ghost records in Salesforce? Whenever there is an auto-number field on an Object, it suddenly seems to have gaps in between? For e.g., if you have a auto-number set at 00001 and the next record it creates is 00004. These gaps are sometimes attributed to people who create records and delete. Auto-number fields Lets talk a bit about auto-number. Apart from the part that they are cool, they are also very stubborn. An auto-number field resets only once in its lifetime and never turns back. When an auto-number is incremented it does not go back, even if the record is deleted. So when you delete a record that has auto-number field on it, it will not decrement it by 1 but instead create the gap. Ghost records The real crux of the issue lies when developers write unit classes. Developers always create dummy records for testing. The test execution runs in a separate context than the main Salesforce. These records are not s...