Loading ...
Sorry, an error occurred while loading the content.

92736Re: VS: [XP] Test Driven Exceptions

Expand Messages
  • Chip Whitmer
    Jun 1, 2004
    • 0 Attachment
      ----- Original Message -----
      From: "Jeff Grigg" <jeffgrigg@...>
      To: <extremeprogramming@yahoogroups.com>
      Sent: Tuesday, June 01, 2004 1:12 PM
      Subject: Re: VS: [XP] Test Driven Exceptions

      > --- "Chip Whitmer" <cwhitmer@m...> wrote:
      > > Now that I think about it: if you're not doing it test-
      > > first, then I guess the boolean mechanism above is safer
      > > than my "simpler" example.
      > Maybe it's a bad habit, but I sometimes test assertion error
      > exceptions into the code, so a 'fail()' method in the 'try' block
      > will, in some cases, get caught and ignored by my own 'catch' blocks.

      Yes -- testing the assertions themselves is the other "gotcha," and is the
      other reason why I added the checks on the caught exception:

      public void testAssertDouble() {
      try {
      assertDouble( 0.3, (double) 2 / 5 );
      fail( "assertDouble() should have failed" );
      } catch( AssertionFailedError x ) {
      assertEquals( "expected:<0.3> but was:<0.4>", x.getMessage() );

      I still find this more expressive than the boolean approach, but it's
      probably just personal preference at this point.

      I will grant that the failure that is finally reported by JUnit is a little
      confusing -- something like this:
      "expected:<expected:<0.3> but was:<0.4>> but was:<assertDouble() should
      have failed>"

      - Chip Whitmer
    • Show all 15 messages in this topic