[ next ] [ prev ] [ contents ] [ skip to More Tests for Story Three ] XP-Cinti TDD Workshop

Scoring Tests

Our first scoring test is easy. The score for an empty board should be 0.

# file: testnet.rb
...
  def test_score_empty_board
    assert_equal 0, @net.score(:BLACK)
    assert_equal 0, @net.score(:WHITE)
  end
...

Running the tests give us the predictable "undefined method 'score'" result, so we add score to the Net class. Remember to write no more code than is necessary to make the test pass.

# file: net.rb
...
  def score(player)
    0
  end
...

And the tests pass!


[ next ] [ prev ] [ contents ] [ skip to More Tests for Story Three ] Copyright 2003 by Jim Weirich.
Some Rights Reserved