Results 1 to 2 of 2
  1. #1
    nikosa is offline Member
    Join Date
    Nov 2008
    Posts
    20
    Rep Power
    0

    Question JUnit Test??? What is it all about????? Please help!!

    Hello Guys,


    Can anybody direct me to a web page that has an absolute beginner JUnitTest tutorials that will also talk about testing not only public but also private methods(if you can test them somehow) and also testing methods that their contents are affected from instances of other objects.

    I am completely confused with this testing and whenever I am looking over the internet they have either the easiest examples (of testing a domain's class getters and setters)

    I would also like to ask how can we test gui components?

    ex.

    private JPanel floor()
    {
    JPanel p = new JPanel();
    p.add(new JTextField(5));
    return p;
    }

    Is it possible to test a method like the one above?????

    ---------------------

    Just in case that the above method was identical but instead of private it was public I would create a new class testclass that will extend the TestCase and I would do..

    public void testFloor(){

    //the name of the class that the floor() belongs is called WeightPanel;

    WeightPanel wp = new WeightPanel();

    JPanel p = wp.floor();
    Assert.assertTrue(p!=null);
    }

    Is it ok, what should I change?

    ------------------------------------


    In addition, having the following method (validateInputAndProceed) how can somebody test it???

    private String [] inputs;
    private JTextFiled floorTF, ....

    public boolean validateInputAndProceed()
    {
    inputs = new String [7];

    String propertyCharacter = (String)propertyCharacterCB.getSelectedItem();

    inputs[0] = floorTF.getText();
    inputs[1] = bedroomTF.getText();
    inputs[2] = closeToAmenitiesTF.getText();
    inputs[3] = garageTF.getText();
    inputs[4] = gardenTF.getText();
    inputs[5] = securityTF.getText();
    inputs[6] = balconyTF.getText();

    for(int i = 0; i<inputs.length; i++)
    if(!re.getDataManagerObject().validateNumberForWei ght(inputs[i])){
    Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(null, "You have entered incorrect values in the field. Please try again..", "Error", JOptionPane.ERROR_MESSAGE);
    return false;
    }

    int action = JOptionPane.showConfirmDialog(null, "Are you sure you want to update the current weights?","Update Weights",JOptionPane.OK_CANCEL_OPTION);
    if(action == JOptionPane.OK_OPTION)
    if(re.getDataManagerObject().updateUserWeights(re. getDataManagerObject().transformPropertyCharacter( propertyCharacter), inputs))
    return true;

    return false;
    }


    Can you please help!!! I think I don't get how the JUnit works!!!!

  2. #2
    vogella is offline Member
    Join Date
    Aug 2009
    Location
    Heidelberg
    Posts
    47
    Rep Power
    0

Similar Threads

  1. JUnit Test Help!
    By pharo in forum New To Java
    Replies: 0
    Last Post: 04-10-2009, 05:15 PM
  2. Junit
    By Azndaddy in forum New To Java
    Replies: 6
    Last Post: 06-15-2008, 06:47 AM
  3. Junit test
    By alice in forum New To Java
    Replies: 1
    Last Post: 06-14-2008, 01:24 AM
  4. Replies: 0
    Last Post: 04-05-2008, 12:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •