Next Generation Java Testing: TestNG and Advanced Concepts
暫譯: 下一代 Java 測試:TestNG 與進階概念
Cédric Beust, Hani Suleiman
- 出版商: Addison Wesley
- 出版日期: 2007-11-01
- 定價: $1,980
- 售價: 8.0 折 $1,584
- 語言: 英文
- 頁數: 512
- 裝訂: Paperback
- ISBN: 0321503104
- ISBN-13: 9780321503107
-
相關分類:
Java 程式語言
立即出貨 (庫存 < 3)
買這商品的人也買了...
-
$580$464 -
$880$695 -
$1,590$1,511 -
$980$774 -
$1,190$1,166 -
$1,095An Introduction To Enterprise Architecture, 2/e (Paperback)
-
$350$298 -
$1,900$1,805 -
$990$891 -
$600$480 -
$720$569 -
$720$612 -
$780$616 -
$690$587 -
$490$387 -
$750$593 -
$450$351 -
$650$514 -
$980$833 -
$850$723 -
$540$459 -
$950$808 -
$450$351 -
$520$411 -
$580$458
商品描述
Description
Enterprise Java developers must achieve broader, deeper test coverage, going beyond unit testing to implement functional and integration testing with systematic acceptance. Next Generation Java™ Testing introduces breakthrough Java testing techniques and TestNG, a powerful open source Java testing platform.
Cédric Beust, TestNG's creator, and leading Java developer Hani Suleiman, present powerful, flexible testing patterns that will work with virtually any testing tool, framework, or language. They show how to leverage key Java platform improvements designed to facilitate effective testing, such as dependency injection and mock objects. They also thoroughly introduce TestNG, demonstrating how it overcomes the limitations of older frameworks and enables new techniques, making it far easier to test today's complex software systems.
Pragmatic and results-focused, Next Generation Java™ Testing will help Java developers build more robust code for today's mission-critical environments.
This book
- Illuminates the tradeoffs associated with testing, so you can make better decisions about what and how to test
- Introduces TestNG, explains its goals and features, and shows how to apply them in real-world environments
- Shows how to integrate TestNG with your existing code, development frameworks, and software libraries
- Demonstrates how to test crucial code features, such as encapsulation, state sharing, scopes, and thread safety
- Shows how to test application elements, including JavaEE APIs, databases, Web pages, and XML files
- Presents advanced techniques: testing partial failures, factories, dependent testing, remote invocation, cluster-based test farms, and more
- Walks through installing and using TestNG plug-ins for Eclipse, and IDEA
- Contains extensive code examples
Whether you use TestNG, JUnit, or another testing framework, the testing design patterns presented in this book will show you how to improve your tests by giving you concrete advice on how to make your code and your design more testable.
Table of Contents
Foreword xiii
Preface xv
Acknowledgments xxi
About the Authors xxiiiChapter 1: Getting Started 1
- Beyond JUnit 3 3
JUnit 4 7
Designing for Testability 8
TestNG 17
Conclusion 21Chapter 2: Testing Design Patterns 23
- Testing for Failures 23
Factories 34
Data-Driven Testing 39
Asynchronous Testing 67
Testing Multithreaded Code 71
Performance Testing 83
Mocks and Stubs 90
Dependent Testing 103
Inheritance and Annotation Scopes 113
Test Groups 119
Code Coverage 132
Conclusion 150Chapter 3: Enterprise Testing 153
- A Typical Enterprise Scenario 154
A Concrete Example 157
Test Implementation 160
Exploring the Competing Consumers Pattern 182
The Role of Refactoring 186
Conclusion 194Chapter 4: Java EE Testing 197
- In-Container versus Out-of-Container Testing 198
In-Container Testing 200
Java Naming and Directory Interface (JNDI) 207
Java Database Connectivity (JDBC) 210
Java Transaction API (JTA) 215
Java Messaging Service (JMS) 219
Java Persistence API (JPA) 225
Enterprise Java Beans 3.0 (EJB3) 236
Java API for XML Web Services (JAX-WS) 246
Servlets 255
XML 262
Conclusion 266Chapter 5: Integration 269
- Guice 280
DbUnit 295
HtmlUnit 303
Selenium 310
Swing UI Testing 312
Tests for Painting Code 316
Continuous Integration 320
Conclusion 322Chapter 6: Extending TestNG 325
- The TestNG API 325
BeanShell 335
Method Selectors 341
Annotation Transformers 346
Reports 355
Writing Custom Annotations 366
Conclusion 375Chapter 7: Digressions 377
- Motivation 377
The TestNG Philosophy 378
The Care and Feeding of Exceptionsv378
Stateful Tests 382
The Pitfalls of Test-Driven Development 385
Testing Private Methods 388
Testing versus Encapsulation 391
The Power of Debuggers 392
Logging Best Practices 394vThe Value of Time 397
Conclusion 399Appendix A: IDE Integration 401
- Eclipse 401
IntelliJ IDEA 411Appendix B: TestNG Javadocs 421
- JDK 1.4 and JDK 5 421
Shortcut Syntax for JDK 5 Annotations 423
Annotation Javadocs 423
The org.testng.TestNG Class 428
The XML API 432Appendix C: testng.xml 435
- Overview 436
Scopes 437
XML Tags 437Appendix D: Migrating from JUnit 449
- JUnitConverter 449
Integrated Development Environments 453
Incremental Migration and JUnit Mode 455
Converting JUnit Code 456Index 471
商品描述(中文翻譯)
**描述**
企業 Java 開發人員必須實現更廣泛、更深入的測試覆蓋,超越單元測試,實施功能測試和整合測試,並進行系統性的驗收。《下一代 Java™ 測試》介紹了突破性的 Java 測試技術和 TestNG,一個強大的開源 Java 測試平台。
TestNG 的創建者 Cédric Beust 和領先的 Java 開發者 Hani Suleiman,展示了強大且靈活的測試模式,這些模式幾乎可以與任何測試工具、框架或語言一起使用。他們展示了如何利用旨在促進有效測試的 Java 平台關鍵改進,例如依賴注入和模擬對象。他們還徹底介紹了 TestNG,演示了它如何克服舊框架的限制並啟用新技術,使測試當今複雜的軟體系統變得更加容易。
務實且以結果為導向的《下一代 Java™ 測試》將幫助 Java 開發人員為當今的關鍵任務環境構建更穩健的代碼。
本書
- 闡明與測試相關的權衡,使您能夠更好地決定測試什麼和如何測試
- 介紹 TestNG,解釋其目標和特性,並展示如何在實際環境中應用它們
- 展示如何將 TestNG 與您現有的代碼、開發框架和軟體庫整合
- 演示如何測試關鍵代碼特性,例如封裝、狀態共享、範圍和線程安全
- 展示如何測試應用程序元素,包括 JavaEE API、數據庫、網頁和 XML 文件
- 提出高級技術:測試部分失敗、工廠、依賴測試、遠程調用、基於集群的測試農場等
- 指導安裝和使用 Eclipse 和 IDEA 的 TestNG 插件
- 包含大量代碼示例
無論您使用 TestNG、JUnit 還是其他測試框架,本書中介紹的測試設計模式將向您展示如何通過提供具體建議來改善您的測試,使您的代碼和設計更具可測試性。
**目錄**
前言 xiii
序言 xv
致謝 xxii
關於作者 xxiv
第 1 章:入門 1
超越 JUnit 3 3
JUnit 4 7
設計可測試性 8
TestNG 17
結論 21
第 2 章:測試設計模式 23
測試失敗 23
工廠 34
數據驅動測試 39
非同步測試 67
測試多線程代碼 71
性能測試 83
模擬和存根 90
依賴測試 103
繼承和註解範圍 113
測試組 119
代碼覆蓋 132
結論 150
第 3 章:企業測試 153
典型企業場景 154
具體示例 157
測試實施 160
探索競爭消費者模式 182
重構的角色 186
結論 194
第 4 章:Java EE 測試 197
容器內測試與容器外測試 198
容器內測試 200
Java 命名和目錄介面 (JNDI) 207
Java 數據庫連接 (JDBC) 210
Java 事務 API (JTA) 215
Java 消息服務 (JMS) 219
Java 持久性 API (JPA) 225
企業 Java Beans 3.0 (EJB3) 236
Java XML 網路服務 API (JAX-WS) 246
Servlets 255
XML 262
結論 266
第 5 章:整合 269
Guice 280
DbUnit 295
HtmlUnit 303
Selenium 310
Swing UI 測試 312
繪圖代碼的測試 316
持續整合 320
結論 322
第 6 章:擴展 TestNG 325
TestNG API 325
BeanShell 335
方法選擇器 341
註解轉換器 346
報告 355
編寫自定義註解 366
結論 375
第 7 章:題外話 377
動機 377
TestNG 哲學 378
異常的處理與維護 378
有狀態的測試 382
測試驅動開發的陷阱 385
測試私有方法 388
測試與封裝 391
除錯器的力量 392
日誌最佳實踐 394
時間的價值 397
結論 399
附錄 A:IDE 整合 401
Eclipse 401
IntelliJ IDEA 411
附錄 B:TestNG Javadocs 421
JDK 1.4 和 JDK 5 421
JDK 5 註解的快捷語法 423
註解 Javadocs 423
org.testng.TestNG 類 428
XML API 432
附錄 C:testng.xml 435
概述 436
範圍 437
XML 標籤 437
附錄 D:從 JUnit 遷移 449
JUnitConverter 449
集成開發環境 453
增量遷移和 JUnit 模式 455
轉換 JUnit 代碼 456
索引 471