Jumper测试
测试点:
- Jummper是否会跳出边界
-
Test Code
// @file: Part3/JumperTest.java // @line: 15~23 @Test public void test1() { /* * case: Boundary */ ActorWorld world = new ActorWorld(); Jumper alice = new Jumper(); world.add(new Location(0, 9), alice); assertEquals(false, alice.canJump()); }
- Jumper移动方向上第一个cell有花
-
Test Code
// @file: Part3/JumperTest.java // @line: 26~36 @Test public void test2() { /* * case: Flower on the first cell in direction */ ActorWorld world = new ActorWorld(); Jumper alice = new Jumper(); Flower flower = new Flower(); world.add(new Location(2, 3), alice); world.add(new Location(1, 3), flower); assertEquals(true, alice.canJump()); }
- Jumper移动方向上第一个cell有石头
-
Test Code
// @file: Part3/JumperTest.java // @line: 38~49 @Test public void test3() { /* * case: Rock on the first cell in direction */ ActorWorld world = new ActorWorld(); Jumper alice = new Jumper(); Rock rock = new Rock(); world.add(new Location(2, 3), alice); world.add(new Location(1, 3), rock); assertEquals(true, alice.canJump()); }
- Jumper移动方向上第二个cell上有花
-
Test Code
// @file: Part3/JumperTest.java // @line: 51~62 @Test public void test4() { /* * case: Flower on the second cell in direction */ ActorWorld world = new ActorWorld(); Jumper alice = new Jumper(); Flower flower = new Flower(); world.add(new Location(2, 3), alice); world.add(new Location(0, 3), flower); assertEquals(true, alice.canJump()); }
- Jumper移动方向上第二个cell上有石头
-
Test Code
// @file: Part3/JumperTest.java // @line: 65~75 @Test public void test5() { /* * case: Rock on the second cell in direction */ ActorWorld world = new ActorWorld(); Jumper alice = new Jumper(); Rock rock = new Rock(); world.add(new Location(2, 3), alice); world.add(new Location(0, 3), rock); assertEquals(false, alice.canJump()); }