java 相关问题(三)
十三、java 实现 调用 打印机 代码详解
??? 接口 PrintService 是 DocPrintJob 的工厂。PrintService 描述了打印机的功能,并可查询它来了解打印机支持的属性。
?
?
?
?
?
?
?
?? 接口 PrintService 是 DocPrintJob 的工厂。PrintService 描述了打印机的功能,并可查询它来了解打印机支持的属性。
?
??
?
十四、JUnit 测试全部 case (TestSuite)??? 如果你不想要讓 TestRunner 找出預設的 testXXX()方法來執行測試,則可以使用TestSuite 來組合你想要執行的測試。例如:
??? 正如先前的範例,此時在TestSuite的建構式中,會以反射找出所有testXXX()方法、建立TestCase實例並加入TestSuite中。
??? 所以基本上,真正用來組合單元測試是TestSuite。TestSuite的addTest()接受的是Test介面的實作物件,所以TestCase與TestSuite都可以加入某個TestSuite中,另一個addTestSuite()方法名稱有點令人困惑,它並非接受TestSuite的實例,而是接受Class的實例,而它只不過是個代為建立TestSuite的簡便方法:public void run(TestResult result) { for (Enumeration e= tests(); e.hasMoreElements(); ) { if (result.shouldStop() ) break; Test test= (Test)e.nextElement(); runTest(test, result); }}public void runTest(Test test, TestResult result) { test.run(result);}?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?