[SalesForce] Unit testing code which has logic around last login date of user

I need to write unit testing code which has logic around system field last login date of user.As per spring'16 release salesforce has added method for setting created date like below.

Test.setCreatedDate(recordId, createdDatetime)

Sets CreatedDate for a test-context sObject.

Is there anything similar method to set system field 'lastlogindate' of user.

Best Answer

I don't think this is possible. You can create users see here but not set last login.

In cases like this before I've refactored code to allow test data to be injected.

Related Topic