You need to sign in to do that
Don't have an account?
anschoewe
Cannot test emptyRecycleBin
I'm trying to verify that my code is permanently deleting objects. For some reason, the test still finds the newly inserted tasks when I query ALL ROWS -even though I just purged it from the recycle bin. Any ideas how I can test that a record was purged from the recycle bin successfully?
Any help is appreciated,
Andrew
Here's my test code:
static testMethod void testPermanentDelete() { Task t = new Task( Subject = 'subject', Priority = 'Normal', Status = 'Completed', ActivityDate = Date.today()); insert t; Id taskId = t.Id; //Verify the task was inserted List<Task> foundTasks = [Select Id From Task Where Id = :taskId ALL ROWS]; System.assertEquals(1, foundTasks.size()); Test.startTest(); Database.DeleteResult[] deleteResults = Database.delete(foundTasks, false); Database.EmptyRecycleBinResult[] emptyRecycleBinResults = Database.emptyRecycleBin(foundTasks); Test.stopTest(); //Verify the task was permanently deleted foundTasks = [Select Id From Task Where Id = :taskId ALL ROWS]; System.assertEquals(0, foundTasks.size()); }
I would try checking the deleteResults and the emptyRecycleBinResults have isSuccess = true, because one of those may be failing (and the database methods don't throw an exception that yo uwould see in your test result)