You need to sign in to do that
Don't have an account?
Yosef Kapta
Replicate user logging in via Salesforce 1 Mobile App in Apex Test Class
I've created a trigger that checks the LoginHistory object for ''Salesforce1 for iOS'' to enforce an Apex validation rule. The short version is that State and Country picklists are not supported by SF1, however we want to make Country and City required, but users still want to be able to create accounts via SF1, hence the trigger.
Any ideas on what my test logic should be? Obviously I would need to trigger it by inserting the code, but how do I add the user element to the logic? Unfortuantely LoginHistory.Application is not a writeable field, therefore I can't hardcode a value - I would need to insert an object in order for this field to be returned, what object should I be looking for?
Thank you for your help.
Any ideas on what my test logic should be? Obviously I would need to trigger it by inserting the code, but how do I add the user element to the logic? Unfortuantely LoginHistory.Application is not a writeable field, therefore I can't hardcode a value - I would need to insert an object in order for this field to be returned, what object should I be looking for?
Thank you for your help.
One way i've solved similar issues in the past was a 1-2 punch of Static variable in a utility class, and some additional logic within the class being tested itself. something like this:
Then in your actual class where you're looking to see if something has been logged you can extend your IF check to be something like this:
and finally in your test: