Pragmatic unit testing in Java with JUnit


Pragmatic unit testing in Java with JUnit

Andy Hunt, Dave Thomas

(Pragmatic starter kit series, 2)

Pragmatic Bookshelf, c2004

大学図書館所蔵 件 / 3



"The Pragmatic Programmers"--P. [1] of cover

Includes bibliographical references (p. 139) and index


  • Introduction
  • Your first unit tests
  • Writing tests in JUnit
  • What to test : the right-BICEP
  • CORRECT boundary conditions
  • Using mock objects
  • Properties of good tests
  • Testing on a project
  • Design issues



Learn how to improve your Java coding skills using unit testing. Despite it's name, unit testing is really a coding technique, not a testing technique. Unit testing is done by programmers, for programmers. It's primarily for our benefit: we get improved confidence in our code, better ability to make deadlines, less time spent in the debugger, and less time beating on the code to make it work correctly. This book shows how to write tests, but more importantly, it goes where other books fear to tread and gives you concrete advice and examples of what to test - the common things that go wrong in all of our programs. Discover the tricky hiding places where bugs breed, and how to catch them using the freely available JUnit framework. It's easy to learn how to think of all the things in your code that are likely to break. We'll show you how with helpful mnemonics, summarized in a handy tip sheet to help you remember all this stuff. With this book you will: write better code, and take less time to write it; discover the tricky places where bugs breed; learn how to think of all the things that could go wrong; test individual pieces of code without having to include the whole project; and test effectively with the whole team. We'll also cover how to use Mock Objects for testing, how to write high quality test code, and how to use unit testing to improve your design skills. We'll show you frequent "gotchas" - along with the fixes - to save you time when problems come up. We'll show you how with helpful mnemonics, summarized in a handy tip sheet. But the best part is that you don't need a sweeping mandate to change your whole team or your whole company. You don't need to adopt Extreme Programming or Test-Driven Development, or change your development process in order to reap the proven benefits of unit testing. You can start unit testing, the pragmatic way, right away.


About the Starter Kit Preface 1 Introduction 1.1 Coding With Confidence 1.2 What is Unit Testing? 1.3 Why Should I Bother with Unit Testing? 1.4 What Do I Want to Accomplish? 1.5 How Do I Do Unit Testing? 1.6 Excuses For Not Testing 1.7 Roadmap 2 Your First Unit Tests 2.1 Planning Tests 2.2 Testing a Simple Method. 2.3 More Tests 3 Writing Tests in JUnit 3.1 Structuring Unit Tests 3.2 JUnit Asserts 3.3 JUnit Framework 3.4 JUnit Test Composition 3.5 JUnit Custom Asserts 3.6 JUnit and Exceptions 3.7 More on Naming 3.8 JUnit Test Skeleton 4 What to Test: The Right-BICEP 4.1 Are the Results Right? 4.2 Boundary Conditions 4.3 Check Inverse Relationships 4.4 Cross-check Using Other Means 4.5 Force Error Conditions 4.6 Performance Characteristics 5 CORRECT Boundary Conditions 5.1 Conformance 5.2 Ordering 5.3 Range 5.4 Reference 5.5 Existence 5.6 Cardinality 5.7 Time 5.8 Try It Yourself 6 Using Mock Objects 6.1 Simple Stubs 6.2 Mock Objects 6.3 Testing a Servlet 6.4 Easy Mock Objects 7 Properties of Good Tests 7.1 Automatic 7.2 Thorough 7.3 Repeatable 7.4 Independent 7.5 Professional 7.6 Testing the Tests 8 Testing on a Project 8.1 Where to Put Test Code 8.2 Test Courtesy 8.3 Test Frequency 8.4 Tests and Legacy Code 8.5 Tests and Reviews 9 Design Issues 9.1 Designing for Testability 9.2 Refactoring for Testing 9.3 Testing the Class Invariant 9.4 Test-Driven Design 9.5 Testing Invalid Parameters A Gotchas A.1 As Long As The Code Works A.2 "Smoke" Tests A.3 "Works On My Machine" A.4 Floating-Point Problems A.5 Tests Take Too Long A.6 Tests Keep Breaking A.7 Tests Fail on Some Machines A.8 My main is Not Being Run B Installing JUnit B.1 Command-line installation B.2 Does it work? C JUnit Test Skeleton C.1 Helper Class C.2 Basic Template D Resources D.1 On The Web D.2 Bibliography E Summary: Pragmatic Unit Testing F Answers to Exercises

「Nielsen BookData」 より

関連文献: 1件中  1-1を表示