dbtest.java
来自「著名的uncle Bob的Agile software development的」· Java 代码 · 共 44 行
JAVA
44 行
import junit.framework.*;
import junit.swingui.TestRunner;
public class DBTest extends TestCase
{
public static void main(String[] args)
{
TestRunner.main(new String[]{"DBTest"});
}
public DBTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
DB.init();
}
public void tearDown() throws Exception
{
DB.close();
}
public void testConnection() throws Exception
{
assert(!DB.con.isClosed());
}
public void testStoreRetrieveDeleteSalariedEmployee() throws Exception
{
int id = 6;
SalariedEmployee original = new SalariedEmployee( id, "Young Bob", 12334 );
assertEquals( 0, DB.getNumberOfEmployees() );
DB.store( original );
assertEquals( 1, DB.getNumberOfEmployees() );
SalariedEmployee expected = DB.retrieve(id);
assertEquals( expected, original );
DB.delete(id);
assertEquals( 0, DB.getNumberOfEmployees() );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?