0

For a method:

@AuraEnabled
public static String login(String username, String password, String startUrl) {
    try{
        ApexPages.PageReference lgn = Site.login(username, password, startUrl);
        aura.redirect(lgn);
        return null;
    }
    catch (Exception ex) {
        return ex.getMessage();            
    }
}

I have this unit test:

  static void testLoginWithInvalidCredentials() {
      System.assertEquals('Argument 1 cannot be null', LightningLoginFormController.login('testUser', 'fakepwd', null));
 }

A method "login" just throw a null - shouldn't it throw an error? This is what exception I got in my unit test:

System.AssertException: Assertion Failed: Expected: Argument 1 cannot be null, Actual: null

Should I fix a method in test or a method in a normal class?

1
  • You can't assume how a method has error handling implemented, though ideally the documentation should be explicit on that.
    – Keith C
    Feb 4 at 15:32

Your Answer

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

Browse other questions tagged or ask your own question.