• Maheshwar
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,

My method will return true if there are any records in the LoginHistory for the currently logged in User in the last two hours.
Now, I'm trying to create a test class to cover this method.
So, in the test class, I need to login to salesforce org as a test user in order to create a record on LoginHistory.

Someone please help me with this scenario.

Thanks,
Mahesh
Hi,

My method will return true if there are any records in the LoginHistory for the currently logged in User in the last two hours.
Now, I'm trying to create a test class to cover this method.
So, in the test class, I need to login to salesforce org as a test user in order to create a record on LoginHistory.

Someone please help me with this scenario.

Thanks,
Mahesh
I have a trigger that utilizes the Last Login field on the user record (you need to have logged in within a certain period of time to start getting a case load assigned to you), but I can't seem to figure out how to simulate a test user logging into salesforce on a test class.  I've tried inserting a UserLogin record manually to create the needed "Last Login" record, but no dice... the system wouldn't let me.  Is there some other way that I could simulate the act of a test user logging into salesforce after I've created that test user?

Any ideas would be welcome.