- Server - 呼叫startService()後,以Socket丟入一個請求,收到回應後執行stopService(),若2秒內沒回應則測試失敗。stopService()後若丟入請求沒有發生錯誤,也視同測試失敗。
- Handler - 傳入一個InputStream(可以用ByteArrayInputStream,把測試字串序列化),與OutputStream(可以用ByteArrayOutputStream,把結果反序列化成字串),看OutputStream的結果是否如預期。測試文件請用XML格式,並使用以下階層:
<Request type="product_query" >
<account level="0" />
<product id="00101001"/>
</Request> - RequestAnalyzer - 類似上述的做法,並對回傳的Request做檢驗,看是否確實取出元素。
- Responder - 類似上述做法,Request的值可以自己訂。
- ProductDataSource - 先寫open()、close()的狀態測試,測試addProduct後可以得到商品,及removeProduct後無法得到商品。getCategorySet和getCategory也一樣。其他部分先擱著。
- ContentProvider - 測試每次由getConnection()得到的Connection不是null,isClosed()也不能是true。對open()、close()做狀態的測試。
- AccountDataSource - 同ProductDataSource。
http://tw-yen.no-ip.org/images/RSs.png
紅色框框圍住的為界接介面,以黑色框框圍住的則是實作細節。
沒有留言:
張貼留言