jeudi 30 avril 2015

JUnit Testing equivalence partitioning, where parameters are being received from JTextField rather than being passed into method

Ok so Im a bit confused and cant find a clear answer to my question.What I want to do is check if an input condition specifies a range of values ie. Greater than one char.I have already handled for this in my code but need to create the JUnit for some testing as part of a college assignment.I will post my code here. This is the method I want to check and it is in a class called AccountCreation.

Thanks

public void CreateAccountButtonClicked()
    {
        //check database for username multiple entries 
        DbCheck check = new DbCheck();
        String userName = textField.getText();
        String password = passwordField.getText();
        //if statement to make sure username and password have at least one character
        if(userName.length()<1 ||password.length()<1)
        {
            JOptionPane.showMessageDialog(null, "Please Enter at least one character in each field");
        }
        else{
        boolean checkCredentials = check.checkAcc(userName);
        if(checkCredentials == false)
        {
            int score=0;
            DbConnect connect = new DbConnect();
            connect.setData(userName,password,score);


            this.setVisible(false);
            new GameSelection().setVisible(true);
        }
        else
        {
            //inform user if user name is already taken.
            JOptionPane.showMessageDialog(null, "User name already exists");
        }
        }


    }
}

Aucun commentaire:

Enregistrer un commentaire