function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MuraliKrishna G 1MuraliKrishna G 1 

How to cover the test class for site.login method in siteregistration controller?

Please help me to cover the pending lines of code in siteregister controller
Raj VakatiRaj Vakati
Can u try this code


https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites.htm

​​​​​​​
/**
 * Test class.
 */
@isTest
private class SiteRegisterControllerTest {
    // Test method for verifying the positive test case
    static testMethod void testRegistration() {
        SiteRegisterController controller = new SiteRegisterController();
        controller.username = 'test@force.com';
        controller.email = 'test@force.com';
        controller.communityNickname = 'test';
        // registerUser always returns null when the page isn't accessed as a guest user
        System.assert(controller.registerUser() == null);
        controller.password = 'abcd1234';
        controller.confirmPassword = 'abcd123';
        System.assert(controller.registerUser() == null);
    }
}

 
Raj VakatiRaj Vakati
Can you check the debug logs what value you are getting the userId ? 
Make sure you are getting not null value 
MuraliKrishna G 1MuraliKrishna G 1
Hi Raj, thanks for reply.. I tried above code ,and i am getting null in userid.