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

Re: [XP] Behaviour Driven Development

Expand Messages
  • Dale Emery
    Hi Ben, ... The primary principle I use to organize tests is The Principle of Rapid Fault Identification: If one or more of these assertions were to fail,
    Message 1 of 106 , Oct 2, 2005
    • 0 Attachment
      Hi Ben,

      > For example, I recently coded a solution to the Bowling Kata
      > and this is one of the methods I created.
      >
      > public void testIntialStateOfGame() {
      > assertFalse(game.isOver());
      > assertFalse(game.currentFrame().isOver());
      > assertEquals(0, game.getScore());
      > }
      >
      > It works, but am I really testing 3 aspects of one thing, or
      > am I actually testing 3 different things?

      The primary principle I use to organize tests is The Principle of
      Rapid Fault Identification: If one or more of these assertions
      were to fail, what organization would lead me as quickly as
      possible to the faulty code? Using your example, I want this as
      three separate test methods so that if one fails, the others can
      still run and give me further information. If I write these as
      one test method, the first failed assertion aborts the method,
      and I never find out whether the subsequent assertions pass or fail.

      A sub-principle I use is The Principle of Independent Utility:
      If the results of the assertions might be independently useful to
      me in identifying the fault, I organize them into separate tests
      so that one failure doesn't prevent me from getting the useful
      information from the others. If the other results are likely to
      be just noise, I organize the assertions into one test method so
      that the first failed assertion precludes the others and
      suppresses the noise.

      I use The Principle of Rapid Fault Identification also for
      naming: If this test were to fail, what name would lead me as
      quickly as possible to the faulty code? For the example you
      give, I might name the three test methods something like this:

      GameIsNotOverWhenFirstCreated()
      CurrentFrameIsNotOverWhenGameIsFirstCreated()
      NoScoreWhenGameIsFirstCreated()

      I might come up with better names with a little more thought (or
      at a time of day other than 5:30am). For example, I'd like to
      write "NotOver" into a positive. Perhaps
      GameIsInProgressWhenFirstCreated().

      The best test namer in the universe is Brian Button. I've
      studied his test names, and they tend to have three parts:
      <desired-result><coordinator><conditions>

      For example: GameIsNotOverWhenCreated()
      - Desired Result: Game is not over
      - Coordinator: when
      - Conditions: first created

      These few principles have given a big boost to my testing.

      Dale

      --
      Dale Emery, Consultant
      Inspiring Leadership for Software People
      Web: http://www.dhemery.com
      Weblog: http://www.dhemery.com/cwd
    • Jeff Grigg
      ... It s those inductive loops they put in the rectangular cuts just before (and often crossing) the stop lines. I figure they must use those to read your
      Message 106 of 106 , Oct 14, 2005
      • 0 Attachment
        --- Ron Jeffries <ronjeffries@X...> wrote:
        > I was thinking "smart light". We have that story in our
        > list here in Michigan. The green arrow only goes on if
        > there are people wanting to turn. (I don't know how the
        > light knows what people want but I guess it's just
        > really intuitive. ;->)

        It's those inductive loops they put in the rectangular cuts just
        before (and often crossing) the stop lines. I figure they must use
        those to read your mind -- with some kind of magnetic field. ;->


        http://www.stjohns.ca/cityservices/traffic/howsignalswork.jsp

        http://auto.howstuffworks.com/question234.htm

        http://www.tfhrc.gov/pubrds/septoct98/loop.htm
      Your message has been successfully submitted and would be delivered to recipients shortly.