Forum Stats

  • 3,874,309 Users
  • 2,266,718 Discussions


Noob question in JUnit.

843810 Member Posts: 46,938
Hello all.
Starts to use JUnit in NetBeans 5.5. But can`t understand how it works.
Have such simple code:
     * Test of isCloseTime method, of class stInterface.TestSettings.
    public void testIsCloseTime() {
        boolean expResult = true;
        boolean result = true;
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail(expResult + " is not equal " + result);
The push Alt+F6 for test starting and get:
true is not equal true

Please, expalain me, what I have done wrong?


  • 800387
    800387 Member Posts: 5,078
    The assertEquals passes (since true is equal to true). However, you have a line invoking fail right below. This will throw an AssertionError indicating the test has failed. Remove or comment out the line containing the fail invocation (as the auto-generated comments clue you to do).

    - Saish
This discussion has been closed.