
Pragmatic Unit Testing in Java 8 with JUnit
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Pragmatic Unit Testing in Java 8 With JUnit steps you through all the important unit testing topics. If you've never written a unit test, you'll see screen shots from Eclipse, IntelliJ IDEA, and NetBeans that will help you get past the hard part--getting set up and started.
Once past the basics, you'll learn why you want to write unit tests and how to effectively use JUnit. But the meaty part of the book is its collected unit testing wisdom from people who've been there, done that on production systems for at least 15 years: veteran author and developer Jeff Langr, building on the wisdom of Pragmatic Programmers Andy Hunt and Dave Thomas. You'll learn:
- How to craft your unit tests to minimize your effort in maintaining them.
- How to use unit tests to help keep your system clean.
- How to test the tough stuff.
- Memorable mnemonics to help you remember what's important when writing unit tests.
- How to help your team reap and sustain the benefits of unit testing.
You won't just learn about unit testing in theory--you'll work through numerous code examples. When it comes to programming, hands-on is the only way to learn!
More details
Other editions
Additional editions

Person
Content
- Cover
- Table of Contents
- Foreword
- Preface
- Why Unit Testing
- Who This Book Is For
- What You Need
- How to Use This Book
- Code and Online Resources
- Acknowledgments
- Part I-Unit-Testing Foundations
- 1. Building Your First JUnit Test
- Reasons to Write a Unit Test
- Learning JUnit Basics: Our First Passing Test
- Arrange, Act, and Assert Your Way to a Test
- Is the Test Really Testing Anything?
- After
- 2. Getting Real with JUnit
- Understanding What We're Testing: The Profile Class
- Determining What Tests We Can Write
- Covering One Path
- Tackling a Second Test
- Initializing Tests with @Before Methods
- How Ya Feelin' Now?
- After
- 3. Digging Deeper into JUnit Assertions
- Assertions in JUnit
- Three Schools for Expecting Exceptions
- After
- 4. Organizing Your Tests
- Keeping Tests Consistent with AAA
- Testing Behavior Versus Testing Methods
- Relationship Between Test and Production Code
- The Value of Focused, Single-Purpose Tests
- Tests as Documentation
- More on @Before and @After (Common Initialization and Cleanup)
- Green Is Good: Keeping Our Tests Relevant
- After
- Part II-Mastering Manic Mnemonics!
- 5. FIRST Properties of Good Tests
- FIRST It Helps to Remember That Good Tests Are FIRST
- [F]IRST: [F]ast!
- F[I]RST: [I]solate Your Tests
- FI[R]ST: Good Tests Should Be [R]epeatable
- FIR[S]T: [S]elf-Validating
- FIRS[T]: [T]imely
- After
- 6. What to Test: The Right-BICEP
- [Right]-BICEP: Are the Results Right?
- Right-[B]ICEP: Boundary Conditions
- Remembering Boundary Conditions with CORRECT
- Right-B[I]CEP: Checking Inverse Relationships
- Right-BI[C]EP: Cross-Checking Using Other Means
- Right-BIC[E]P: Forcing Error Conditions
- Right-BICE[P]: Performance Characteristics
- After
- 7. Boundary Conditions: The CORRECT Way
- [C]ORRECT: [C]onformance
- C[O]RRECT: [O]rdering
- CO[R]RECT: [R]ange
- COR[R]ECT: [R]eference
- CORR[E]CT: [E]xistence
- CORRE[C]T: [C]ardinality
- CORREC[T]: [T]ime
- After
- Part III-The Bigger Design Picture
- 8. Refactoring to Cleaner Code
- A Little Bit o' Refactor
- Finding Better Homes for Our Methods
- Automated and Manual Refactorings
- Taking Refactoring Too Far?
- After
- 9. Bigger Design Issues
- The Profile Class and the SRP
- Extracting a New Class
- Command-Query Separation
- The Cost of Maintaining Unit Tests
- Other Design Thoughts
- After
- 10. Using Mock Objects
- A Testing Challenge
- Replacing Troublesome Behavior with Stubs
- Changing Our Design to Support Testing
- Adding Smarts to Our Stub: Verifying Parameters
- Simplifying Testing Using a Mock Tool
- One Last Simplification: Introducing an Injection Tool
- What's Important to Get Right When Using Mocks
- After
- 11. Refactoring Tests
- Searching for an Understanding
- Test Smell: Unnecessary Test Code
- Test Smell: Missing Abstractions
- Test Smell: Irrelevant Information
- Test Smell: Bloated Construction
- Test Smell: Multiple Assertions
- Test Smell: Irrelevant Details in Test
- Test Smell: Misleading Organization
- Test Smell: Implicit Meaning
- Adding a New Test
- After
- Part IV-The Bigger Unit-Testing Picture
- 12. Test-Driven Development
- The Primary Benefit of TDD
- Starting Simple
- Adding Another Increment
- Cleaning Up Our Tests
- Another Small Increment
- Supporting Multiple Answers: A Small Design Detour
- Expanding the Interface
- Last Tests
- Tests As Documentation
- The Rhythm of TDD
- After
- 13. Testing Some Tough Stuff
- Testing Multithreaded Code
- Testing Databases
- After
- 14. Testing on a Project
- Coming up to Speed
- Getting on the Same Page with Your Team
- Convergence with Continuous Integration
- Code Coverage
- After
- A1. Setting Up JUnit in IntelliJ IDEA and NetBeans
- IntelliJ IDEA
- NetBeans
- Index
- - SYMBOLS -
- - DIGITS -
- - A -
- - B -
- - C -
- - D -
- - E -
- - F -
- - G -
- - H -
- - I -
- - J -
- - L -
- - M -
- - N -
- - O -
- - P -
- - Q -
- - R -
- - S -
- - T -
- - U -
- - V -
- - W -
- - Z -
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.