万本电子书0元读

万本电子书0元读

顶部广告

Testing with JUnit电子书

售       价:¥

30人正在读 | 0人评论 9.8

作       者:Frank Appel

出  版  社:Packt Publishing

出版时间:2015-08-27

字       数:108.3万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:此类商品不支持退换货,不支持下载打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
No matter what your specific background as a Java developer is, unit testing is the way to go. This book provides you with a comprehensive, but concise entrance, advancing your knowledge, step-wise, to a professional level.
目录展开

Testing with JUnit

Table of Contents

Testing with JUnit

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. Getting Started

Why you should busy yourself with unit tests

Reducing the defect rate

Improving the code quality

Increasing the development pace

Enhancing the specification density

Boosting confidence and courage

Setting the table

Choosing the ingredients

Organizing your code

Serving the starter

Introducing the example app

Understanding the nature of a unit test

Writing the first test

Evaluating test results

Writing tests first

Summary

2. Writing Well-structured Tests

The four phases of a unit test

Using a common test structure

Setting up the fixture

What goes up must come down

Verification

Choosing the next functionality to test

Start with the happy path

Conclude with corner cases

After the war

Getting the test names right

Test prefix

Behavior-expressing patterns

Reducing names to the essentials

Summary

3. Developing Independently Testable Units

Decomposing requirements

Separating concerns

Component dependencies

Understanding isolation

Delegating responsibilities to DOCs

Indirect input and output

Unit isolation with test doubles

Working with test doubles

Placeholder dummies

Fake it till you make it

Providing indirect input with stubs

Recording interactions with spies

Verifying behavior with mocks

Increasing efficiency with mock frameworks

The promised land?

Basic stubbing

Indirect output verification

Using test helpers

Motivation

The test helper class

The test helper object

Summary

4. Testing Exceptional Flow

Testing patterns

Using the fail statement

Annotated expectations

Verification with the ExpectedException rule

Capturing exceptions with closures

Treating collaborators

Fail fast

The stubbing of exceptional behavior

Summary

5. Using Runners for Particular Testing Purposes

Understanding the architecture

What are runners good for?

Looking at the big picture

Writing your own extension

Using custom runners

Furnishing a suite with test cases

Structuring suites into categories

Populating suites automatically

How about creating test doubles with annotations?

Writing dataset tests

Using parameterized tests

Reducing glue code with JUnitParams

Increasing the expressiveness of test descriptions with Burst

Summary

6. Reducing Boilerplate with JUnit Rules

Understanding rules

What are JUnit rules?

Writing your own rule

Configuring the fixture with annotations

Working with advanced concepts

Using ClassRules

The ordering of rule execution

Employing custom solutions

Working with system settings

Ignoring tests conditionally

Summary

7. Improving Readability with Custom Assertions

Working with the JUnit built-in assert approach

Understanding the basics

Reviewing the file session storage

Verifying the storage behavior

Improving readability with assertion helpers

Creating flexible expressions of intent with Hamcrest

Using matcher expressions

Writing custom matchers

Writing fluently readable assertions with AssertJ

Employing assertion chains

Creating your own asserts

Summary

8. Running Tests Automatically within a CI Build

Wrapping up the sample application

Refining the architecture

Separating concerns into modules

Setting up an automated CI build

What is continuous integration?

Principles and practices

Creating your own build

Integrating code coverage reports

Enlarging on code coverage

Automating reporting

Summary

A. References

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部