Instant Hands-on Testing with PHPUnit How-to
暫譯: 即時實作 PHPUnit 測試指南

Michael Lively

  • 出版商: Packt Publishing
  • 出版日期: 2013-05-20
  • 售價: $1,260
  • 貴賓價: 9.5$1,197
  • 語言: 英文
  • 頁數: 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 是一個框架,旨在幫助開發者解決這個問題。它提供了一個功能豐富的環境,擁有大多數必要的工具,以便為任何專案提供充分的測試。

《Instant Hands-on Testing with PHPUnit How-to》提供了 PHPUnit 框架所提供功能的全面概述。它展示了框架中眾多功能如何用於為現實世界的專案編寫測試,以確保它們按您預期的方式運行並將繼續運行。

本書將展示如何設置必要的架構,以便在您的專案中使用 PHPUnit 執行單元測試。它將引導您了解如何編寫基本測試以及如何維護專案的測試套件。您將學習如何使用 PHPUnit 的一些進階功能,然後看到如何使用模擬物件來隔離您正在測試的代碼。我們還將探索如何創建測試來驗證您與資料庫的互動,甚至看到如何使用 PHPUnit 來了解您實際上正在測試的代碼。

在本書結束時,您將擁有開始為您的專案添加測試所需的所有基本理解。本書為成為編寫單元測試的專家提供了良好的基礎。

您將從本書中學到的內容
- 以標準方式將 PHPUnit 引入您的專案
- 理解 PHPUnit 測試的結構
- 創建數據提供者,以快速針對多個數據集創建測試
- 使用 PHPUnit 的骨架生成器從測試生成代碼或從代碼生成測試
- 聲明測試依賴性,以幫助隔離測試失敗
- 測試抽象類、特徵和受保護的方法
- 在您的單元測試中測試資料庫互動

方法
本書充滿了實用的逐步指導和對最重要和有用任務的清晰解釋。這是一本 Packt Instant How-to 指南,提供簡潔明瞭的食譜,幫助您開始使用 PHPUnit 進行代碼測試和提高代碼質量。

本書的讀者對象
《Instant Hands-on Testing with PHPUnit How-to》是為對編寫準確代碼有興趣的 PHP 開發者而寫的。如果您是 PHPUnit 的新手,本書將為您提供理解如何使用 PHPUnit 為您的專案編寫測試的堅實基礎。如果您已經對 PHPUnit 有初步了解,本書將激發您對一些更難理解的 PHPUnit 概念的興趣。