EMMA Coverage Report (generated Fri Mar 15 09:08:15 CET 2013)
[all classes][jpacman.model]

COVERAGE SUMMARY FOR SOURCE FILE [GameTestCase.java]

nameclass, %method, %block, %line, %
GameTestCase.java100% (1/1)100% (3/3)100% (147/147)100% (24/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GameTestCase100% (1/1)100% (3/3)100% (147/147)100% (24/24)
<static initializer> 100% (1/1)100% (20/20)100% (1/1)
GameTestCase (): void 100% (1/1)100% (3/3)100% (1/1)
setUpGame (): void 100% (1/1)100% (124/124)100% (22/22)

1package jpacman.model;
2 
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNull;
5import static org.junit.Assert.assertTrue;
6 
7import org.junit.Before;
8 
9/**
10 * This is a JUnit test class, intended for use in
11 * cases where a filled Pacman board is necessary.
12 * This class creates such a filled board, and offers
13 * various instance variables to access parts of the
14 * board. Typical clients of this class will inherit
15 * the game and its content from this class.
16 * <p>
17 * @author Arie van Deursen; Aug 23, 2003
18 * @version $Id: GameTestCase.java,v 1.6 2008/02/10 12:51:55 arie Exp $
19 */
20public abstract class GameTestCase {
21 
22    /**
23     * The game that we're setting up for testing purposes.
24     */
25    protected Game theGame;
26 
27    /**
28     * The player of the game.
29     */
30    protected Player thePlayer;
31 
32    /**
33     * One of the monsters in the game.
34     */
35    protected Monster theMonster;
36 
37    /**
38     * A food element.
39     */
40    protected Food theFood;
41 
42    /**
43     * Series of cells containing differen types of guests.
44     */
45    protected Cell playerCell, wallCell, monsterCell, foodCell, emptyCell;
46 
47    /**
48     * Simple map that can be used for various testing purposes.
49     * It contains every type of guest, as well as several empty cells.
50     */
51    public static final String[] SIMPLE_MAP =
52        new String[]{
53        "0W0",
54        "FP0",
55        "FM0",
56        "0WM"
57    };
58 
59 
60    /**
61     * Setup a game that can be used in test cases
62     * defined in subclasses of this class.
63     */
64    @Before
65    public void setUpGame() {
66        theGame = new Game(SIMPLE_MAP);
67 
68        Board theBoard = theGame.getBoard();
69 
70        wallCell = theBoard.getCell(1, 0);
71        assertTrue(wallCell.getInhabitant() instanceof Wall);
72        assertEquals(Guest.WALL_TYPE, wallCell.getInhabitant().guestType());
73 
74        monsterCell = theBoard.getCell(1, 2);
75        assertTrue(monsterCell.getInhabitant() instanceof Monster);
76        assertEquals(Guest.MONSTER_TYPE,
77                monsterCell.getInhabitant().guestType());
78 
79        foodCell = theBoard.getCell(0, 1);
80        assertTrue(foodCell.getInhabitant() instanceof Food);
81        assertEquals(Guest.FOOD_TYPE, foodCell.getInhabitant().guestType());
82 
83        playerCell = theBoard.getCell(1, 1);
84        assertTrue(playerCell.getInhabitant() instanceof Player);
85        assertEquals(Guest.PLAYER_TYPE, playerCell.getInhabitant().guestType());
86 
87        emptyCell = theBoard.getCell(2, 1);
88        assertNull(emptyCell.getInhabitant());
89 
90        thePlayer = theGame.getPlayer();
91        theMonster = (Monster) monsterCell.getInhabitant();
92        theFood = (Food) foodCell.getInhabitant();
93 
94        assertTrue(theGame.getMonsters().contains(theMonster));
95        assertEquals(2, theGame.getMonsters().size());
96    }
97}

[all classes][jpacman.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov