0

I have written a batch class that updates a field on Case object with the owner name which is assigned by Case assignment rule. When I try to test this batch class, a part of the code which runs after case history retrieval , is not covered.
Could it be because of the delay in case assignment rule that there is no history record? How to overcome this issue? Any suggestions appreciated.

0
0

I'm afraid you won't be able to do that in a simple way. To my knowledge when running unit tests, nothing actually is committed to database, so no history records will be created. Also, the History tables are ReadOnly so you won't be able to create any fake data. My suggestion would be to use 'Test.isRunningTest' to return some mock data (keep in mind that those records would be filled with nulls as they're readOnly).

Not the answer you're looking for? Browse other questions tagged or ask your own question.