Instant Hands-on Testing with PHPUnit How-to

Michael Lively

  • 出版商: Packt Publishing
  • 出版日期: 2013-05-20
  • 售價: $1,240
  • 貴賓價: 9.5$1,178
  • 語言: 英文
  • 頁數: 82
  • 裝訂: Paperback
  • ISBN: 178216958X
  • ISBN-13: 9781782169581
  • 相關分類: PHP
  • 海外代購書籍(需單獨結帳)

相關主題

商品描述

A practical guide to getting started with PHPUnit to improve code quality with this book and ebook

Overview

  • Learn something new in an Instant! A short, fast, focused guide delivering immediate results
  • Discover how to make best use of PHPUnit in your projects
  • Get started with code testing using PHPUnit in no time
  • Learn how to use PHPUnit like a seasoned veteran

In Detail

No developer wants to accept the inherent difficulty of writing software as an excuse for not finding the bugs in our code before anyone else does. PHPUnit is a framework that was created to allow developers to solve that very problem. It provides a feature-rich environment with most of the tools necessary to provide adequate tests for any project.

"Instant Hands-on Testing with PHPUnit How-to" provides a thorough overview of the functionality provided by the PHPUnit framework. It shows how the plethora of features in the framework can be used to write tests for real world projects to ensure they function and will continue to function in the ways that you expect.

This book will show how you can set up the scaffolding necessary to run unit tests in your project with PHPUnit. It will walk you through the process of how to write a basic test and how to maintain your project’s test suite. You will learn how to use some of the more advanced features of PHPUnit and then see how you can use mock objects to isolate the code you are testing. We will then discover how to create tests that verify your interaction with databases and even see how you can use PHPUnit to understand which code you are actually testing.

At the end of the book you will have all of the basic understanding necessary to begin adding tests to your project. This book provides a great foundation for becoming a expert at writing unit tests.

What you will learn from this book

  • Bootstrap PHPUnit into your project in a standard way
  • Understand the anatomy of a PHPUnit test
  • Create data providers to quickly create tests against multiple datasets
  • Use PHPUnit’s skeleton generator to generate code from tests or tests from code
  • Declare test dependencies to help isolate test failures
  • Test abstract classes, traits, and protected methods
  • Test database interactions in your unit tests

Approach

Filled with practical, step-by-step instructions and clear explanations for the most important and useful tasks. This is a Packt Instant How-to guide, which provides concise and clear recipes for getting started with PHPUnit for performing code testing and improving code quality.

Who this book is written for

"Instant Hands-on Testing with PHPUnit How-to" is for PHP developers that have an appreciation for writing accurate code. If you are new to PHPUnit, it will give you a solid foundation for understanding how to use PHPUnit to write tests for your projects. If you already have a cursory understanding of PHPUnit it will whet your appetite for some of the more difficult-to-understand concepts in PHPUnit.

商品描述(中文翻譯)

一本實用指南,教你如何使用PHPUnit來提升程式碼品質的書籍和電子書。

概述:
- 快速、簡潔的指南,立即獲得成果
- 學習如何在專案中充分運用PHPUnit
- 迅速上手使用PHPUnit進行程式碼測試
- 學習如何像經驗豐富的專家一樣使用PHPUnit

詳細內容:
沒有開發者願意將撰寫軟體的困難性作為不找出程式碼中的錯誤的藉口。PHPUnit是一個框架,旨在讓開發者解決這個問題。它提供了一個功能豐富的環境,擁有大部分為任何專案提供足夠測試的工具。

《即時實戰PHPUnit測試指南》全面介紹了PHPUnit框架提供的功能。它展示了如何使用框架中的各種功能來為真實專案撰寫測試,以確保它們按照預期的方式運作並持續運作。

本書將展示如何設置PHPUnit在專案中運行單元測試所需的基礎結構。它將引導您完成撰寫基本測試的過程,以及如何維護專案的測試套件。您將學習如何使用PHPUnit的一些高級功能,並了解如何使用模擬物件來隔離您正在測試的程式碼。然後,我們將發現如何創建驗證與資料庫互動的測試,甚至看到如何使用PHPUnit來了解您實際正在測試的程式碼。

在本書結束時,您將具備開始為專案添加測試所需的基本理解。本書為成為撰寫單元測試專家打下了堅實的基礎。

本書將教您以下內容:
- 在專案中以標準方式引入PHPUnit
- 理解PHPUnit測試的結構
- 創建資料提供者以快速建立對多個資料集的測試
- 使用PHPUnit的骨架生成器從測試生成程式碼,或從程式碼生成測試
- 宣告測試相依性以幫助隔離測試失敗
- 測試抽象類別、特性和受保護方法
- 在單元測試中測試與資料庫的互動

方法:
本書提供了實用、逐步指示和清晰解釋,針對最重要和最有用的任務。這是Packt的即時指南,提供了簡潔明瞭的食譜,讓您快速入門PHPUnit,進行程式碼測試和提升程式碼品質。

本書適合對撰寫準確程式碼有興趣的PHP開發者。如果您對PHPUnit尚不熟悉,本書將為您提供建立專案測試的堅實基礎。如果您已經對PHPUnit有基本了解,本書將激發您對PHPUnit中一些較難理解的概念的興趣。