snaketest.java
来自「一个贪吃蛇游戏」· Java 代码 · 共 57 行
JAVA
57 行
/**
* @(#)SnakeTest.java
* @Unit tests for Snake class.
*
* @Link Scholes
* @version 1.00 2008/7/24
*/
package Test;
import junit.framework.*;
import Data.*;
public class SnakeTest extends TestCase
{
//The Snake instance for test.
private Snake snake = null;
//Set up the testing environment.
protected void setUp()
{
snake = new Snake(0);
}
//Returns the test suite of this class.
public static Test suite()
{
return new TestSuite(Snake.class);
}
//Accuracy test for contructor Snake().
public void testSnake()
{
assertNotNull("The instance should not be null.",snake);
}
//Accuracy test for getLength().
public void testGetLength()
{
assertEquals("The length should be correct",1,snake.getLength());
}
//Accuracy test for increase().
public void testIncrease()
{
snake.increase();
assertEquals("The length should be correct",2,snake.getLength());
}
//Accuracy test for decrease().
public void testDecrease()
{
snake.increase();
snake.decrease();
assertEquals("The length should be correct",1,snake.getLength());
}
} //end class SnakeTest
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?