
hii.... how to create junit of methods having parameters passed in it..... for example : plz dont refer any link. Just help me by junit of this code.
public boolean validateUser(final Display display) {
int noOfAttempts = 0;
while(3 > noOfAttempts++){
final Login loginDialog = new Login(display,true);
loginDialog.createContents();
if(!loginDialog.isLoginAttempted()){
return false;
}
if(loginDialog.isAuthenticationSuccessful().booleanValue()){
return true;
}
}
thanksssss...

//Assumptions /* Login is a class and contains validateUser method. Display is a final class and may contain methods showing Gender related properties with age as parameter. There are two scenarios possible here. If authenticated successfully, the result is true. In this scenario, pass the parameters to validateUser method which gets passed uner if(loginDialog.isAuthenticationSuccessful().booleanValue()){ return true; */
junit can be written below as follows but it is the sample only, if code is provided, fully it can be prepared
public void testAuthenticatedValidateUser() { Login login = new Login(); boolean result = login.ValidateUser(Display.maleWith18Years()); assert.assertNotNull(?Resultant is null?,result); assert.assertEquals("User is not validated and fails in authentication",?false?,String.valueOf(result)); }
public void testValidateUserThatNotLoggedIn() { Login login = new Login(); boolean result = login.ValidateUser(Display.maleBelow18Years()); assert.assertNotNull(?Resultant is null?,result); assert.assertTrue("User is not logged in at all ",?false?,String.valueOf(result)); }
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.