Test Driven Development in Ruby: A Practical Introduction to TDD Using Problem and Solution Domain Analysis

Test Driven Development in Ruby: A Practical Introduction to TDD Using Problem and Solution Domain Analysis

Test Driven Development in Ruby: A Practical Introduction to TDD Using Problem and Solution Domain Analysis
Автор: Paranj Bala
Дата выхода: 2017
Издательство: Apress Media, LLC.
Количество страниц: 302
Размер файла: 2.8 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

 Contents

About the Author

About the Technical Reviewer

Foreword

Acknowledgments

Introduction

Chapter 1: The Basics

Terminology

Kata

Coding Kata

Domain

Problem Domain

Solution Domain

Domain Expert

Domain Knowledge

Defining the Problem Domain and the Solution Domain

Learning TDD

Learning by Coding Kata

Learning Retrospective

Intent vs. Implementation

Intent

Implementation

Intent and Implementation

Music

Lyrics

Home Plan

Separate Intent from Implementation

Sheep Example

Test API Example

Bowling Game Example

Precision in Language and Meaning

Tests Are Executable Documentation

Shift in Mental State

Overview of TDD

Test Driven Development

The Five Steps of TDD

Failing Test

Writing a Failing Test

Minimal Implementation

Refactoring

Separation of Intent from Implementation

Ping Pong Pair Programming Technique

Black Box Perspective

Shift in System and Mental States

Importance of Discipline

Overcoming Difficulty

Problem-Solving Skills

Four Phases of Problem Solving

Understand the Problem

Devise a Plan

Carry Out the Plan

Look Back

Subskills of Test Driven Development

Problem Domain Analysis

Solution Domain Analysis

Alternative Representations

Divide and Conquer Strategy

Designing Test Cases

Sum a List of Numbers

Sequence of Test Cases

Starter Test

Next Test

Story Test

Assertion

Test Driving Calculator

Canonical Test Structure

Given

When

Then

Arrange, Act, Assert

Calculator

Addition

Subtraction

Common Mistakes

Common Mistakes in the TDD Cycle

Mistakes in Step One

Mistakes in Step Two

Mistakes in Step Three

Mistakes in Step Four

Mistakes in Step Five

Base Conversion

Problem Statement

Problem Domain Analysis

Solution Domain Analysis

Algorithm

Code

Code Reflecting Test Data

Multiple Assertions

Vowel Checker

Forgetting to Test the Negative Case

Not Testing the Boundary Conditions

Not Updating the Tests

Implementation-Aware Tests

Summary

Chapter 2: Katas

Fibonacci Sequence

Problem Statement

Problem Domain Analysis

Solution Domain Analysis

Assumptions

Test-Driven Fibonacci

Fizz Buzz

Problem Statement

Problem Domain Analysis

Solution Domain Analysis

Test-Driven FizzBuzz

No if-else Constraint

No if Constraint

Implementation-Independent Tests

Crossing the System Boundary

Mocking as a Design Technique

Abstraction Levels in a System

Testing Random Behavior

Testing Time-Dependent Behavior

Simulating User Input

Open Closed Principle

Difference Reduction

Defect Localization

Stack

Basic Stack

Test Precisely and Concretely

Make Your Code Robust

The Sieve of Eratosthenes

Algorithm

Prime Factors

Problem Statement

Problem Domain Analysis

Solution Domain Analysis

Summary

Chapter 3: Techniques in TDD

Obvious Implementation

Fake It Till You Make It

Triangulation

Addition

Sum a List of Numbers

Problem Domain Analysis

Solution Domain Analysis

Initial Condition

Steps to Solve the Problem

Algorithm Description

Assumptions

Test Cases

Solution Domain Analysis Redux

Reduction

Problem Statement

Example....1

Example....2

Steps to Solve the Problem

Iterative Construct

Initial Conditions

Euclidean Algorithm

Test-Driven GCD

Transformation Priority Premise

Refactorings and Transformations

Transformation List

Counter

Problem Statement

Problem Domain Analysis

Solution Domain Analysis

Steps to Solve the Problem

Algorithm

Logical Design

Skeleton Code

Terminating Condition

Initial Condition

Pseudo Code

Test-Driven Counter

Factorial

Summary

Chapter 4: Importance of Test Cases

Problem Statement

Problem Domain Analysis

Solution Domain Analysis

Algorithm Description

Code

Summary

Chapter 5: Character-to-Number Conversion

Problem Statement

Discussion

Solution Domain Analysis

Test Cases

Summary

Chapter 6: Conway’s Game of Life

Problem Statement

Problem Domain Analysis

Assumptions

Solution Domain Analysis

Moore Neighborhood

Test Cases

Test-Driven Game of Life

Application Statement

Refactor Solution

Code Review

Summary

Chapter 7: Gilded Rose

Form vs. Structure

Problem Statement

Initial Setup

Form

Structure

DeMorgan’s Laws

Making Temporal Dependency Explicit

Improving the Structure

Express Intent

Tell-Don’t-Ask Principle

Inheritance

Implementing the New Feature

Express Domain Concepts

Retrospective

Summary

Chapter 8: Dealing with Third-Party APIs

Subscription Plan

Create a Plan

Delete a Plan

Stripe Customer

Subscribe a Customer to a Plan

Test-Driven Stripe Library

Integration Tests

Unit Tests

Make Your Code Robust

Summary

Chapter 9: Pair Ranking

Problem Domain Analysis

Solution

Summary

Index

Learn the basics of test driven development (TDD) using Ruby. You will carry out problem domain analysis, solution domain analysis, designing test cases, and writing tests first. These fundamental concepts will give you a solid TDD foundation to build upon. Test Driven Development in Ruby is written by a developer for developers.The concepts are first explained, then a coding demo illustrates how to apply the theory in practice. At the end of each chapter an exercise is given to reinforce the material. Complete with working files and code samples, you'll be able to work alongside the author, a trainer, by following the material in this book.

What You Will Learn

  • Carry out problem domain analysis, solution domain analysis, designing test cases, and writing tests first
  • Use assertions
  • Discover the structure of a test and the TDD cycle
  • Gain an understanding of minimal implementation, starter test, story test, and next test
  • Handle refactoring using Ruby
  • Hide implementation details
  • Test precisely and concretely
  • Make your code robust

Who This Book Is For

Experienced Ruby programmers or web developers with some prior experience with Ruby.


Похожее:

Список отзывов:

Нет отзывов к книге.