1 Reply Latest reply: Jun 18, 2010 9:02 AM by 800387 RSS

    Noob question in JUnit.

    843810
      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() {
              System.out.println("isCloseTime");
              
              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
      junit.framework.assertionFailedError

      Please, expalain me, what I have done wrong?
        • 1. Re: Noob question in JUnit.
          800387
          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