万本电子书0元读

万本电子书0元读

顶部广告

Learning Behavior-driven Development with JavaScript电子书

售       价:¥

0人正在读 | 0人评论 9.8

作       者:Enrique Amodeo

出  版  社:Packt Publishing

出版时间:2015-02-19

字       数:261.0万

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

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
This book is ideal for any JavaScript developer who is interested in producing well-tested code. If you have no prior experience with testing, Node.js, or any other tool, do not worry, as they will be explained from scratch.
目录展开

Learning Behavior-driven Development with JavaScript

Table of Contents

Learning Behavior-driven Development with JavaScript

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

Errata

Piracy

Questions

1. Welcome to BDD

The test-first approach

The test-first cycle

Write a failing test

Make the test pass

Clean the code

Repeat!

Consequences of the test-first cycle

BDD versus TDD

Exploring unit testing

The structure of a test

Test doubles

What is a good test?

Summary

2. Automating Tests with Mocha, Chai, and Sinon

Node and NPM as development platforms

Installing Node and NPM

Configuring your project with NPM

Introducing Mocha

Useful options in Mocha

Our first test-first cycle

More expressive assertions with Chai

Working with the "should" interface

Red/Green/Refactor

Parameterized tests

Organizing your setup

Defining test scenarios

Test doubles with Sinon

Is it traditional TDD or BDD?

Welcome Sinon!

Integrating Sinon and Chai

Summary

3. Writing BDD Features

Introducing myCafé

Writing features

Displaying a customer's order

Tips for writing features

Starting to code the scenarios

Testing asynchronous features

Testing a callback-based API

Testing a promise-based API

Interlude – promises 101

Mocha and promises

Chai-as-Promised

Test doubles with promises

Organizing our test code

The storage object pattern

The example factory pattern

Finishing the scenario

Parameterized scenarios

Finishing our feature

Summary

4. Cucumber.js and Gherkin

Getting started with Gherkin and Cucumber.js

Preparing your project

Writing your first scenario in Gherkin

Executing Gherkin

The World object pattern

Better step handlers

Better reporting

Writing advanced scenarios

Gherkin example tables

Consolidating steps

Advanced setup

Gherkin-driven example factory

Implicit versus explicit setup

The Background section

Parameterized scenarios

Finishing the feature

Useful Cucumber.js features

Tagging features and scenarios

Hooks

The before hook

The after hook

The around hook

Non-English Gherkin

Cucumber.js or Mocha?

Summary

5. Testing a REST Web API

The approach

A strategy to test web APIs

Mocha or Cucumber.js?

The plan

Testing the GET order feature

Exploring our feature a bit

Starting, stopping, and setting up our server

Testing whether the API responds with 200 Ok

Should we use a realistic order object?

Implementing the test

Testing our HAL resource for orders

The contract with the business layer

Finishing the scenario

Testing slave resources

The order actions

Testing embedded resources

Extracting cross-cutting scenarios

Homework!

Summary

6. Testing a UI Using WebDriverJS

Our strategy for UI testing

Choosing the right tests for the UI

The testing architecture

WebDriverJS

Finding and interacting with elements

Complex UI interaction

Injecting scripts

Command control flows

Taking screenshots

Working with several tabs and frames

Testing a rich Internet application

The setup

The test HTML page

Serving the HTML page and scripts

Using browserify to pack our code

Creating a WebDriver session

Testing whether our view updates the HTML

Testing whether our view reacts with the user

What about our UI control logic?

Summary

7. The Page Object Pattern

Introducing the Page Object pattern

Best practices for page objects

A page object for a rich UI

Building a page object that reads the DOM

Building a page object that interacts with the DOM

Testing the navigation

Summary

8. Testing in Several Browsers with Protractor and WebDriver

Testing in several browsers with WebDriver

Testing with PhantomJS

Running in several browsers

The Selenium Server

Welcome Protractor!

Running the tests in parallel

Other useful configuration options

Using the Protractor API

Summary

9. Testing Against External Systems

Writing good test doubles

Testing against external systems

Testing against a database

Accessing the DB directly

Treating the DAO as a collection

Testing against a third-party system

The record-and-replay testing pattern

Summary

10. Final Thoughts

TDD versus BDD

A roadmap to BDD

BDD versus integration testing

BDD is for testing problem domains

Concluding the book

Next steps?

Summary

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部