Junit

Junit

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...

View Answers

September 6, 2012 at 11:11 AM

//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)); }

Ads









Related Tutorials/Questions & Answers:
junit
junit  i want to learn junit for user guidence for easy format to understnad to study. please provide that one
junit
junit  Explain about junit?   Junit is new framework designed for Java to perform unit testing. It is an Open source framework. Junit... ). It helps the developers in designing and writing test cases. Junit also have
Advertisements
Junit
Junit  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
Junit
) { UniversalData.connectionDetails = connectionDetails; }** if i want to make a test case using Junit...; regards Ankit Chauhan   Have a look at the following link: Junit Testing
junit - JUNIT
junit  can u give me a sample application of using junit?  Hi Friend, Please visit the following link: http://www.roseindia.net/junit/ Hope that it will be helpful for you. Thanks
Version of junit>junit dependency
List of Version of junit>junit dependency
Version of junit>junit-dep dependency
List of Version of junit>junit-dep dependency
What is JUnit?
What is JUnit?  What is the use of JUnit? How to write program to test a Java application? Thanks   Hi, JUnit is unit testing tool in Java. You can use the JUnit to test your Java code. Read more at JUnit 4.3.1
Version of junit-addons>junit-addons dependency
List of Version of junit-addons>junit-addons dependency
Version of junit-doclet>junit-doclet dependency
List of Version of junit-doclet>junit-doclet dependency
Artifacts of junit
List of Artifacts of junit maven depenency
spring with junit and mock testing
spring with junit and mock testing  spring with junit mock testing
Junit
JUnit Junit is new framework designed for Java to perform unit testing. It is an Open source framework. Junit is an instance of xUnit architecture... and writing test cases. Junit also have a Graphical User Interface which allows
Version of xdoclet-plugin-junit>xdoclet-plugin-junit dependency
List of Version of xdoclet-plugin-junit>xdoclet-plugin-junit dependency
Version of subpersistence>junit dependency
List of Version of subpersistence>junit dependency
Version of com.celexus>junit dependency
List of Version of com.celexus>junit dependency
Version of jepi>junit dependency
List of Version of jepi>junit dependency
junit 4.12 maven dependency
junit 4.12 maven dependency  Hi, I have to use the JUnit 4.12 in one of my project which heavily uses JUnit for testing code. Earlier it was using old version of JUnit and now it has to be upgraded to JUnit 4.12. What code
Maven Dependency junit >> 3.7
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version3.7 in your project
Maven Dependency junit >> 3.8
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version3.8 in your project
Maven Dependency junit >> 3.8.1
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version3.8.1 in your project
Maven Dependency junit >> 3.8.2
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version3.8.2 in your project
Maven Dependency junit >> 4.0
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.0 in your project
Maven Dependency junit >> 4.1
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.1 in your project
Maven Dependency junit >> 4.10
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.10 in your project
Maven Dependency junit >> 4.11
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.11 in your project
Maven Dependency junit >> 4.11-beta-1
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.11-beta-1 in your project
Maven Dependency junit >> 4.12
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.12 in your project
Maven Dependency junit >> 4.12-beta-1
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.12-beta-1 in your project
Maven Dependency junit >> 4.12-beta-2
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.12-beta-2 in your project
Maven Dependency junit >> 4.12-beta-3
You should include the dependency code given in this page to add Maven Dependency of junit >> junit version4.12-beta-3 in your project

Ads