Auto- number fields value gets skipped while running RUN ALL TEST
|Knowledge Article Number||000176743|
You might notice that records using Auto-number has skips after deploying or after you use the RUN ALL TEST. Since the records created are only dummy records the records will be rolled-back after testing. However, even if the record has been rolled back it does not roll back the auto-number field’s value.
This is working as designed as the System creates records to verify the functionality. The number of record depends on the use of test method and code behind that method. If another number has been claimed in a different transaction between the time of commit and time of rollback, the number will be lost and the number will continue with the latest one used. That's how you end up with a gap.