Unit Testing in Java: How Tests Drive the Code

Johannes Link

買這商品的人也買了...

商品描述

Description:

Software testing is indispensable and is one of the most discussed topics in software development today. Many companies address this issue by assigning a dedicated software testing phase towards the end of their development cycle. However, quality cannot be tested into a buggy application. Early and continuous unit testing has been shown to be crucial for high quality software and low defect rates. Yet current books on testing ignore the developer's point of view and give little guidance on how to bring the overwhelming amount of testing theory into practice. Unit Testing in Java represents a practical introduction to unit testing for software developers. It introduces the basic test-first approach and then discusses a large number of special issues and problem cases. The book instructs developers through each step and motivates them to explore further.

 

Table of Contents:

Part 1: Basic Techniques
1 Introduction
1.1 Important Terms
1.2 XP Testing
1.3 Classic Testing
1.4 "Test-First Development" - A Brief Definition
1.5 Java Only - Or Other Coffee?
1.6 Objectives of This Book
1.7 Organization of This Book
1.8 Conventions in This Book
1.9 Web Site to This Book

2 Automating Unit Tests
2.1 What Do We Want to Automate?
2.2 Requirements to an Automation Framework
2.3 Junit
2.4 Summary

3 Basic Steps of the Test-first Approach
3.1 Step by Step
3.2 Dependencies
3.3 Organizing and Running Tests
3.4 Summary

4 Test Ideas and Heuristics
4.1 Reworking Single Tests
4.2 Black and White Boxes
4.3 Testing the Typical Functionality
4.4 Threshold Values and Equivalence Classes
4.5 Error Cases and Exceptions
4.6 Object Interactions
4.7 Design by Contract
4.8 More Ideas to Find Test Cases
4.9 Refactoring Code and Tests
4.10 Summary

5 The Inner Life of a Test Framework
5.1 Statics
5.2 The Life Cycle of a Test Suite
5.3 Project-specific Expansions
5.4 Summary

6 Dummy and Mock Objects for Independence
6.1 Little Dummies
6.2 Weltering in Technical Terms
6.3 Big Dummies
6.4 Extending our Mansion
6.5 Endoscopic Testing
6.6 Mock Objects from the Assembly Line
6.7 Testing Threshold Values and Exceptions
6.8 How Does the Test Get to the Mock?
6.9 Evil Singletons
6.10 Lightweight and Heavyweight Mocks
6.11 File Dummies
6.12 More Typical Mock Objects
6.13 External Components
6.14 The Pros and Cons
6.15 Summary

7 Inheritance and Polymorphism
7.1 Inheritance
7.2 Polymorphism
7.3 Summary

8. How Much is Enough?
8.1 The XP Rule
8.2 Clear Answers to Clear Questions
8.3 Test Coverage
8.4 Summary

Part II: Advanced Topics
9 Persistent Objects
9.1 Abstract Persistence Interface
9.2 Persistent Dummy
9.3 Designing a Database Interface
9.4 Testing the "Right" Persistence
9.5 Interaction Between Persistence Layer and Client
9.6 Summary

10 Concurrent Programs
10.1 Problems Using Threads
10.2 Testing Asynchronous Services
10.3 Testing for Synchronization
10.4 Summary

11 Distributed Applications
11.1 RMI
11.2 Enterprise JavaBeans
11.3 Summary

12 Web Applications
12.1 Functional Tests
12.2 Testing on the Server
12.3 Testing with Dummies
12.4 Separating the Servlet API from the Servlet Logic
12.5 Testing the HTML Generation
12.6 Summary

13 Graphical User Interfaces
13.1 The Direct Way
13.2 Short Detours
13.3 Summary

14 The Role of Unit Tests in the Software Process
14.1 Activities in the Defined Software Process
14.2 Process Types and Testing Strategies
14.3 Costs and Benefits of Automated Unit Tests
14.4 Commercial Process Models
14.5 Will Automated Unit Tests Fit in My Process?

15 Loose Ends and Opportunities
15.1 Unit Testing for Existing Software
15.2 Introducing Unit Tests to the Development Team
15.3 What's Missing

Part III: Appendix
A. Notes to JUnit
B. Unit Tests with Other Programming Languages
C. Glossary
D. Bibliography & References

商品描述(中文翻譯)

描述:



軟體測試是不可或缺的,也是軟體開發中最被討論的話題之一。許多公司通過在開發週期結束時指派專門的軟體測試階段來解決這個問題。然而,品質無法被測試到有錯誤的應用程式中。早期和持續的單元測試被證明對於高品質的軟體和低缺陷率至關重要。然而,目前關於測試的書籍忽略了開發者的觀點,並且對如何將龐大的測試理論實踐起來提供了很少的指導。《Java單元測試》是軟體開發者的實用入門書,介紹了基本的測試先行方法,並討論了許多特殊問題和問題案例。本書逐步指導開發者並激勵他們進一步探索。






 


目錄:



第一部分:基本技巧
1 引言
1.1 重要術語
1.2 XP 測試
1.3 傳統測試
1.4 '測試先行開發' - 簡要定義
1.5 只有 Java - 還是其他咖啡?
1.6 本書目標
1.7 本書組織
1.8 本書慣例
1.9 本書網站

2 自動化單元測試
2.1 我們想要自動化什麼?
2.2 自動化框架的要求
2.3 Junit
2.4 總結

3 測試先行方法的基本步驟
3.1 逐步進行
3.2 依賴關係
3.3 組織和執行測試
3.4 總結

4 測試思路和啟發法
4.1 重構單一測試
4.2 黑盒和白盒
4.3 測試典型功能
4.4 閾值和等價類別
4.5 錯誤案例和異常
4.6 物件互動
4.7 契約設計
4.8 尋找測試案例的更多思路
4.9 重構程式碼和測試
4.10 總結

5 測試框架的內部運作
5.1 靜態方法
5.2 測試套件的生命週期
5.3 專案特定擴展
5.4 總結

6 為獨立性而使用虛擬和模擬物件
6.1 小小的虛擬物件
6.2 技術術語的混亂
6.3 大型虛擬物件
6.4 擴展我們的大廈
6.5 內視鏡測試
6.6 裝配線上的模擬物件
6.7 測試閾值和異常
6.8 測試如何到達模擬物件?
6.9 邪惡的單例模式
6.10 輕量級和重量級模擬物件
6.11 檔案虛擬物件
6.12 更多典型的模擬物件
6.13 外部組件
6.14 優點和缺點
6.15 總結

7 繼承和多型
7.1 繼承
7.2 多型
7.3 總結

8. 夠不夠?
8.1 XP 原則
8.2 清晰問題的明確答案
8.3 測試覆蓋率
8.4 總結

第二部分:高級主題
9 持久物件
9.1 抽象持久介面
9.2 持久虛擬物件
9.3 設計資料庫介面
9.4 測試'正確'的持久層
9.5 持久層和客戶端的互動
9.6 總結

10 並行程式
10.1 使用執行緒的問題
10.2 測試非同步服務
10.3 測試同步
10.4 總結

11 分散式應用程式
11.1 RMI
11.2 Enterprise JavaBeans
11.3 總結

12 網路應用程式
12.1 功能測試
12.2 伺服器端測試
12.3 使用虛擬物件進行測試
12.4 將 Servlet API 與 Servlet 邏輯分離
12.5 測試 HTML 生成
12.6 總結

13 圖形使用者介面