Next Generation Java Testing: TestNG and Advanced Concepts

Series
Addison-Wesley
Author
Cédric Beust / Hani Suleiman  
Publisher
Addison-Wesley
Cover
Softcover
Edition
1
Language
English
Total pages
512
Pub.-date
October 2007
ISBN13
9780321503107
ISBN
0321503104
Related Titles


Product detail

Product Price CHF Available  
9780321503107
Next Generation Java Testing: TestNG and Advanced Concepts
67.70 approx. 7-9 days

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     xxiii
Chapter 1: Getting Started     1Beyond JUnit 3     3
JUnit 4     7
Designing for Testability     8
TestNG     17
Conclusion     21Chapter 2: Testing Design Patterns     23Testing 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     153A 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     197In-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     269Guice     280
DbUnit     295
HtmlUnit     303
Selenium     310
Swing UI Testing     312
Tests for Painting Code     316
Continuous Integration     320
Conclusion     322Chapter 6: Extending TestNG     325The TestNG API     325
BeanShell     335
Method Selectors     341
Annotation Transformers     346
Reports     355
Writing Custom Annotations     366
Conclusion     375Chapter 7: Digressions     377Motivation     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     401Eclipse     401
IntelliJ IDEA     411Appendix B: TestNG Javadocs     421JDK 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     435Overview     436
Scopes     437
XML Tags     437Appendix D: Migrating from JUnit     449JUnitConverter     449
Integrated Development Environments     453
Incremental Migration and JUnit Mode     455
Converting JUnit Code     456Index     471

Back Cover

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.

Author

Cédric Beust, a senior software engineer at Google, is an active member of the Java Community Process who has been extensively involved in the development of the latest Java release. He is the creator and main contributor to the TestNG project.

Hani Suleiman is CTO of Formicary, a consulting and portal company specializing in financial applications. He is one of two individual members who has been elected to the Executive Committee of the Java Community Process.