Chris Peterson (Apex PM at the time 2021) mentioned in a Richmond Users Group meeting that one could provide a mock implementation of System.FinalizerContext for uint testing TransactionFinalizers. He couldn't remember if it was an abstract or virtual class, or an interface. So, I dug into the definitions as exposed by IC2 and got confused:
Here's FinalizerContextImpl implementing an interface FinalizerContext
global class /*System.*/FinalizerContextImpl implements FinalizerContext
{
global Object clone(){}
global Id getAsyncApexJobId(){}
global Exception getException(){}
global String getRequestId(){}
global ParentJobResult getResult(){}
}
And here's FinalizerContext - a class, not an interface ?!
global class /*System.*/FinalizerContext
{
global Id getAsyncApexJobId(){}
global Exception getException(){}
global String getRequestId(){}
global ParentJobResult getResult(){}
}
So, I don't know if Chris misspoke or IC2 is in error but the path to creating a mock FinalizerContext for unit testing is not as straightforward as I would have thought
Eric