I have two communities with custom login controllers which I want to test.

I am attempting to execute login as described here, but site.login just returns null. Is there a missing piece, like how do you specify which actual portal/site/community you are logging into?

edit: I am not using seeAllData flag though. Is that mandatory?


Site class method always return null if they are not called or run inside Site. This is a standard Salesforce limitation so unfortunately you cannot do much in this case. But you can use

Test.isRunningTest() with the help of this you can cover your test class.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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