Fitnesse Trivia example code notes

30 Nov

The ‘trivia’ example for Fitnesse appears here in their on-line documentation for fixtures.  In the first example they forget to pass along the code for the Player class, so I thought I’d post mine here.  As I said before, it just a simple constructor class, but the other classes won’t compile and the test won’t run without it.

package myFixtures.trivia;

public class Player {
private String playerName;

    public Player(String playerName) {
        this.playerName = playerName;
    }
}

You might notice that the import fit.ColumnFixture; line is missing which you’ll see in the other classes in their example. That’s because I had to be fancy and use the Slim framework instead of Fit. Because of that, my fitnesse page code is different as well:

!define TEST_SYSTEM {slim}
!path /Users/KWHome/Dev/fitnesse/files/examples/

This example uses Slim instead of Fit.

"You can add players to the game, and you can 
 ask the game how many players are playing."

|myFixtures.trivia.AddRemovePlayerFixture|
|playerName  |addPlayer?  |countPlayers? |
|Al          |true        |1             |
|Bertha      |true        |2             |
|Stanley     |true        |3             |

Bear in mind these are just my first fumbling attempts at getting things into place and making sense of this. Snarky comments and kindly offers of ‘a better way’ are both welcome! And please say hello to the third member, Stanley, who wasn’t in the actual example code but insisted on tagging along anyways.

This post also taught me (after a furious bit of Googling) the value of the </pre> tag to format code in posts. Oh, and when you’re editing your Fitnesse table definitions, don’t forget to hit that handy ‘format’ button at the bottom before you hit ‘save’ Makes all the columns nice ‘n even.

Advertisements

Comments are welcome!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: