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

COVERAGE SUMMARY FOR SOURCE FILE [PacmanTest.java]

nameclass, %method, %block, %line, %
PacmanTest.java100% (2/2)75%  (9/12)91%  (88/97)88%  (29/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PacmanTest100% (1/1)71%  (5/7)90%  (76/84)90%  (27/30)
getEngine (): Engine 0%   (0/1)0%   (0/4)0%   (0/1)
main (String []): void 0%   (0/1)0%   (0/4)0%   (0/2)
PacmanTest (): void 100% (1/1)100% (3/3)100% (2/2)
setup (): void 100% (1/1)100% (24/24)100% (4/4)
suite (): Test 100% (1/1)100% (12/12)100% (3/3)
tearDown (): void 100% (1/1)100% (4/4)100% (2/2)
testTopLevelAlphaOmega (): void 100% (1/1)100% (33/33)100% (16/16)
     
class PacmanTest$EmptyMonsterController100% (1/1)80%  (4/5)92%  (12/13)75%  (3/4)
doTick (): void 0%   (0/1)0%   (0/1)0%   (0/1)
PacmanTest$EmptyMonsterController (PacmanTest): void 100% (1/1)100% (6/6)100% (1/1)
PacmanTest$EmptyMonsterController (PacmanTest, PacmanTest$1): void 100% (1/1)100% (4/4)100% (1/1)
start (): void 100% (1/1)100% (1/1)100% (1/1)
stop (): void 100% (1/1)100% (1/1)100% (1/1)

1package jpacman;
2 
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertTrue;
5 
6import java.io.IOException;
7 
8import jpacman.controller.AbstractMonsterController;
9import jpacman.controller.IMonsterController;
10import jpacman.controller.Pacman;
11import jpacman.model.Engine;
12import jpacman.model.GameTestCase;
13import junit.framework.JUnit4TestAdapter;
14import junit.framework.TestSuite;
15 
16import org.junit.After;
17import org.junit.Before;
18import org.junit.Test;
19 
20/**
21 * Systematic acceptance test for Pacman.
22 * It follows the test suite design document,
23 * which in turn follows the Pacman use cases.
24 *
25 * The test cases have been derived by translating the use
26 * cases into test-ready decision tables and state machines,
27 * both available in the JPacman documentation.
28 *
29 * @author Arie van Deursen; 5-sep-2004
30 * @version $Id: PacmanTest.java,v 1.14 2008/02/10 19:28:20 arie Exp $
31 */
32public class PacmanTest extends GameTestCase {
33 
34    /**
35     * The full game, including a gui.
36     */
37    private Pacman myPacman;
38 
39    /**
40     * Set up the full game, making use of the
41     * game model created in the superclass.
42     * @throws IOException if images can't be loaded.
43     */
44    @Before public void setup() throws IOException {
45        myPacman = new Pacman(new Engine(theGame),
46                new EmptyMonsterController());
47        myPacman.start();
48        assertTrue(myPacman.getEngine().inPlayingState());
49    }
50 
51    /**
52     * And, at the end, nicely close the windows.
53     */
54    @After public void tearDown() {
55        myPacman.exit();
56    }
57 
58    /**
59     * Top level test running the default GUI, map, monstercontroller,
60     * observers, etc.
61     * Simple "smoke test" that just executes various methods to make sure that
62     * they don't crash immediately.
63     * More elaborate tests are conducted elsewhere.
64     * The name "alpha-omega" refers to the full cycle this test suite
65     * attempts to make (Binder's terminology).
66     * @throws InterruptedException if threads don't work well
67     * @throws IOException  If the file systems is wrong
68     */
69    @Test public void testTopLevelAlphaOmega()
70    throws InterruptedException, IOException {
71        Pacman p = new Pacman();
72        p.start();
73        p.left();
74        p.right();
75        final int nrOfMonsterMoves = 10;
76        Thread.sleep(AbstractMonsterController.DELAY * nrOfMonsterMoves);
77        p.up();
78        p.down();
79        p.quit();
80        p.start();
81        p.left();
82        p.right();
83        p.up();
84        p.down();
85        p.exit();
86    }
87 
88     // The remaining acceptance test suite heavily depends on
89     // proper implementation of the functionality that has been
90     // left out as an exercise, and hence has been omitted from
91     // this version.
92 
93 
94    /**
95     * A monster controller that doesn't move any monsters,
96     * allowing us to do the moving ourselves in this test suite.
97     */
98    private class EmptyMonsterController implements IMonsterController {
99        public void doTick() { }
100        public void start() { }
101        public void stop() { }
102    }
103 
104    /**
105     * @return The underlying engine.
106     */
107    private Engine getEngine() {
108        return myPacman.getEngine();
109    }
110 
111    /**
112     * Create a JUnit 3.8 Suite object that can be used to exercise
113     * the JUnit 4 test suite from the command line or from ant.
114     * @return A Junit 3.8 test suite containing all test cases.
115     */
116    public static junit.framework.Test suite() {
117        TestSuite s = new TestSuite();
118        s.addTest(new JUnit4TestAdapter(PacmanTest.class));
119        return s;
120    }
121 
122 
123    /**
124     * Actually exercise the Pacman test suite.
125     *
126     * @param args All arguments are ignored.
127     */
128    public static void main(String[] args) {
129        junit.textui.TestRunner.run(jpacman.PacmanTest.suite());
130    }
131}

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