You need to sign in to do that
Don't have an account?
How to cover 100% in my test class?
How to cover 100% coverage for below test class.
It has covered 88% now.
Below lines didn't cover in my test class.Please help to cover this.
Uncovered Lines:
if (success) {
return pr;
}
My class:
public class password {
public String username {get; set;}
public password() {}
public PageReference forgotPassword() {
boolean success = Site.forgotPassword(username);
PageReference pr = Page.ForgotPasswordConfirm;
pr.setRedirect(true);
if (success) {
return pr;
}
return null;
}
public static testMethod void testpassword() {
password controller = new password();
controller.username = 'test@gmail.com';
}
}
Hi James,
Code coverage means the test class should parse through every line in the Class.
Usually we have to write different test records - one to pass and other one to fail. So that both the If and Else are executed.
We also use the assert methods to verify the ex[ected results.
Ex.
Method Add
var (2,2) result 4
System.assert (result = 4 ) [assertion succeeds]
var (2,2) result 0
System.assertnot equals (result=4) [assertion fails]
Regards,
Ashish