Test Driven
Practical TDD and Acceptance TDD for Java Developers
Lasse Koskela
  • September 2007
  • ISBN 9781932394856
  • 544 pages
  • printed in black & white

... very engaging writing style, I was blown away!

Michael Feathers, Consultant, Object Mentor

In test-driven development, you first write an executable test of what your application code must do. Only then do you write the code itself and, with the test spurring you on, improve your design. In acceptance test-driven development (ATDD), you use the same technique to implement product features, benefiting from iterative development, rapid feedback cycles, and better-defined requirements. TDD and its supporting tools and techniques lead to better software faster.

Test Driven brings under one cover practical TDD techniques distilled from several years of community experience. With examples in Java and the Java EE environment, it explores both the techniques and the mindset of TDD and ATDD. It uses carefully chosen examples to illustrate TDD tools and design patterns, not in the abstract but concretely in the context of the technologies you face at work. It is accessible to TDD beginners, and it offers effective and less-well-known techniques to older TDD hands.

Table of Contents show full

preface

acknowledgments

about this book

about the cover illustration

resources

Part 1 A TDD primer

1. The big picture

1.1. The challenge: solving the right problem right

1.2. Solution: being test-driven

1.3. Build it right: TDD

1.4. Build the right thing: acceptance TDD

1.5. Tools for test-driven development

1.6. Summary

2. Beginning TDD

2.1. From requirements to tests

2.2. Choosing the first test

2.3. Breadth-first, depth-first

2.4. Let�s not forget to refactor

2.5. Adding a bit of error handling

2.6. Loose ends on the test list

2.7. Summary

3. Refactoring in small steps

3.1. Exploring a potential solution

3.2. Changing design in a controlled manner

3.3. Taking the new design further

3.4. Summary

4. Concepts and patterns for TDD

4.1. How to write tests and make them pass

4.2. Essential testing concepts

4.3. Closer look into test doubles

4.4. Guidelines for testable designs

4.5. Unit-testing patterns

4.6. Working with legacy code

4.7. Summary

Part 2 Applying TDD to specific technologies

5. Test-driving web components

5.1. MVC in web applications in 60 seconds

5.2. Taming the controller

5.3. Creating the view test-first

5.4. TDD with component-based web frameworks

5.5. Summary

6. Test-driving data access

6.1. Exploring the problem domain

6.2. Driving data access with unit tests

6.3. Writing integration tests before the code

6.4. Integration tests in action

6.5. Populating data for integration tests

6.6. Should I drive with unit or integration tests?

6.7. File-system access

6.8. Summary

7. Test-driving the unpredictable

7.1. Test-driving time-based functionality

7.2. Test-driving multithreaded code

7.3. Standard synchronization objects

7.4. Summary

8. Test-driving Swing

8.1. What to test in a Swing UI

8.2. Patterns for testable UI code

8.3. Tools for testing view components

8.4. Test-driving a view component

8.5. Summary

Part 3 Building products with acceptance TDD

9. Acceptance TDD explained

9.1. Introduction to user stories

9.2. Acceptance tests

9.3. Understanding the process

9.4. Acceptance TDD as a team activity

9.5. Benefits of acceptance TDD

9.6. What are we testing, exactly?

9.7. Brief overview of available tools

9.8. Summary

10. Creating acceptance tests with Fit

10.1. What�s Fit?

10.2. Three built-in fixtures

10.3. Beyond the built-ins with FitLibrary

10.4. Executing Fit tests

10.5. Summary

11. Strategies for implementing acceptance tests

11.1. What should acceptance tests test?

11.2. Implementation approaches

11.3. Technology-specific considerations

11.4. Tips for common problems

11.5. Summary

12. Adopting TDD

12.1. What it takes to adopt TDD

12.2. Getting others aboard

12.3. How to fight resistance

12.4. How to facilitate adoption

12.5. Summary

Appendix A: : Brief JUnit 4 tutorial

Appendix B: : Brief JUnit 3.8 tutorial

Appendix C: : Brief EasyMock tutorial

Appendix D: : Running tests with Ant

index

© 2014 Manning Publications Co.

About the Technology

In test-driven development, you first write an executable test of what your application code must do. Only then do you write the code itself and, with the test spurring you on, improve your design. In acceptance test-driven development (ATDD), you use the same technique to implement product features, benefiting from iterative development, rapid feedback cycles, and better-defined requirements. TDD and its supporting tools and techniques lead to better software faster.

About the book

Test Driven brings under one cover practical TDD techniques distilled from several years of community experience. With examples in Java and the Java EE environment, it explores both the techniques and the mindset of TDD and ATDD. It uses carefully chosen examples to illustrate TDD tools and design patterns, not in the abstract but concretely in the context of the technologies you face at work.

What's inside

  • Hands-on examples of how to test-drive Java code
  • How to avoid common TDD adoption pitfalls
  • ATDD development and the Fit framework
  • How to test Java EE components—Servlets, JSPs, and Spring Controllers
  • How to handle tough issues like multithreaded programs and data-access code

About the reader

It is accessible to TDD beginners, and it offers effective and less-well-known techniques to older TDD hands.

About the author

Lasse Koskela, a methodology specialist at Reaktor Innovations in Finland, has coached dozens of teams in agile methods and practices such as test-driven development.


combo $44.99 pBook + eBook
eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Full of hard-won lessons that take years to learn on your own.

Laurent Bossavit, Consultant, 2006 Gordon Pask Award Winner

Strengthen your quality safety-net with the TDD ideas in this book!

Christopher Haupt, Principal Consultant, Mobirobo LLC

... a well-spring of up-to-date information and practices.

Jason Rogers, Software Engineer, RiskMetrics Group, Inc.

... it's much better on TDD than other books I've read ... including a wonderful job in providing TDD philosophy.

Dave Corun, Architect, Social Solutions