PHPUnit袖珍指南-第一章 简介

翻译 2006年05月20日 01:22:00

第一章 简介

很长时间里,我对“你什么时候会为PHPUnit写一个文档”这个问题的回答是:“你不需要PHPUnit文档,去读读JUnit文档或买一本Junit的书,试一试用PHPPHPUnit来重写JavaJunit的例子”。当我和O’Reilly德国办公室的Barbara WeissAlexandra Follenius这样说的时候,他们鼓励我想想是不是可以写一本书来作为PHPUnit的文档。

1.1 基本要求

本书的主题是PHPUnit,这是一个支持用PHP进行测试驱动开发的开放源代码框架。本书覆盖了PHPUnit 2.3,需要PHP5.1支持。当然,大部分例子在PHPUnit 2.02.2PHP5.0也都可以运行。本书的后半部分,“在PHP4中使用PHPUnit”一章中,覆盖了老式的,不再进一步积极发展的在PHP4中运行的PHPUnit

本书的读者需要对使用PHP5进行面向对象编程要很好的理解。建议德文读者读读我写的Professionelle Softwareentwicklung mit PHP 5一书,这是对使用PHP5进行面向对象编程的介绍。英文读者可以参考Andi Gutmans, Stig BakkenDerick Rethans合著的PHP 5 Power Programming

1.2 本书是自由发布的

本书可以在Creative Commons license版权公约下自由获得。访问http://www.phpunit.de/pocket_guide/你可以总是发现本书的最新版本。你根据自己的需要修改和重新发布。当然,相比你发布你自己的版本,我更推荐你发送反馈和更新给sb@sebastian-bergmann.de

1.3 本书的约定

下面是本书的一些书写约定:

斜体

表示新名词,URL,邮件地址,文件名,文件扩展名,路径名,目录和Unix应用程序

固定宽度字体

表示命令,选项,开关语句,变量,函数,类,名字空间,方法,模块,参数,值,对象,文件内容或命令输出。

固定宽度加重字体

表示需要读者逐字逐句输入的命令或文本内容。

固定宽度斜体

表示需要用读者自己的值替代的文本。

辅助信息

这是一个辅助信息,是建议或者普通注释。它包含了关于相关主题有用的辅助内容。

警告

这是一个提醒注意的警告或注释

1.4 如何联系我们

我们已经尽力测试和验证过本书的内容,但是你还是可能发现特性改变了,甚至有错误!

作为本书的读者,你可以通过发送反馈给我来帮助我们改进未来的版本。请告诉我们任何书中的错误,不精确,臭虫,误导、混淆语句或输入错误。

也请你让我们知道如果能让本书更有用。我们会慎重对待你的来信,并尽力在未来版本加以改进。你可以发信到如下地址:

O'Reilly Media, Inc.

1005 Gravenstein Highway North

Sebastopol, CA 95472

(800) 998-9938 (in the U.S. or Canada)

(707) 829-0515 (international/local)

(707) 829-0104 (fax)

 

如果想问技术问题,或对本书发表评论,可以发送到bookquestions@oreilly.com

PHPUnit口袋书指南的网站列出了例子,勘误表和未来的版本计划。你可以在如下网址找到它们:

http://www.oreilly.com/catalog/phpunitpg

想要更多本书或其他书籍更多信息,请访问O’Reilly的网站:

http://www.oreilly.com

 

1.5 鸣谢

我要感谢Kent BeckErich Gamma发明了Junit给了我发明PHPUnit的灵感,我更要谢谢Kent Beck写了Junit口袋书一书,这使我有了写本书的冲动。同时我要感Allison Randal, Alexandra FolleniusBarbara Weiss,是他们在O’Reilly负责本书。

我要感谢Andi Gutmans, Zeev SuraskiMarcus Börger,是他们开发了PHP5的核心Zend Engine 2。我还有谢谢Derick Rethans,他开发了PHP扩展功能Xdebug,使得PHPUnit的代码覆盖率功能成为可能。最后,我还有谢谢Michiel Rook,他写了PhingPHPUnit任务。

 

--------------------------------------------------------------------------------------------------------------

原文:

Chapter 1. Introduction

For a very long time, my answer to the question, "When will you write documentation for PHPUnit?" has been, "You do not need documentation for PHPUnit. Just read the documentation for JUnit or buy a book on JUnit and adapt the code examples from Java™ and JUnit to PHP and PHPUnit." When I mentioned this to Barbara Weiss and Alexandra Follenius from the O'Reilly Germany office, they encouraged me to think it over and write a book that would serve as the documentation for PHPUnit.

 

1.1. Requirements

The topic of this book is PHPUnit, an open source framework for test-driven development with the PHP programming language. This book covers Version 2.3 of PHPUnit, which requires PHP 5.1. However, most of the examples should work with PHPUnit Versions 2.02.2, as well as PHP 5.0. The "PHPUnit for PHP 4" section, later in this book, covers the older, no longer actively developed version of PHPUnit for PHP 4.

 

The reader should have a good understanding of object-oriented programming with PHP 5. To German readers, I recommend my book Professionelle Softwareentwicklung mit PHP 5 as an introduction to object-oriented programming with PHP 5. A good English book on the subject is PHP 5 Power Programming by Andi Gutmans, Stig Bakken, and Derick Rethans (Prentice Hall PTR).

 

1.2. This Book Is Free

This book is available under the Creative Commons license. You will always find the latest version of this book at its web site: http://www.phpunit.de/pocket_guide/. You may distribute and make changes to this book however you wish. Of course, rather than distribute your own private version of the book, I would prefer you send feedback and patches to sb@sebastian-bergmann.de.

 

1.3. Conventions Used in This Book

The following is a list of the typographical conventions used in this book:

 

 

 

Italic

 

Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames, directories, and Unix utilities.

 

Constant width

 

Indicates commands, options, switches, variables, functions, classes, namespaces, methods, modules, parameters, values, objects, the contents of files, or the output from commands.

 

Constant width bold

 

Shows commands or other text that should be typed literally by the user.

 

Constant width italic

 

Shows text that should be replaced with user-supplied values.

 

You should pay special attention to notes set apart from the text with the following styles:

 

TIP

This is a tip, suggestion, or general note. It contains useful supplementary information about the topic at hand.

 

WARNING

This is a warning or note of caution.

 

1.4. How to Contact Us

We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!).

 

As a reader of this book, you can help us to improve future editions by sending us your feedback. Please let us know about any errors, inaccuracies, bugs, misleading or confusing statements, and typos that you find anywhere in this book.

 

Please also let us know what we can do to make this book more useful to you. We take your comments seriously and will try to incorporate reasonable suggestions into future editions. You can write to us at:

 

O'Reilly Media, Inc.

1005 Gravenstein Highway North

Sebastopol, CA 95472

(800) 998-9938 (in the U.S. or Canada)

(707) 829-0515 (international/local)

(707) 829-0104 (fax)

To ask technical questions or to comment on the book, send email to:

 

bookquestions@oreilly.com

The web site for PHPUnit Pocket Guide lists examples, errata, and plans for future editions. You can find this page at:

 

http://www.oreilly.com/catalog/phpunitpg

For more information about this book and others, see the O'Reilly web site:

 

http://www.oreilly.com

 

1.5. Acknowledgments

I would like to thank Kent Beck and Erich Gamma for JUnit and for the inspiration to write PHPUnit. I would also like to thank Kent Beck for his JUnit Pocket Guide, which sparked the idea for this book. I would like to thank Allison Randal, Alexandra Follenius, and Barbara Weiss for sponsoring this book at O'Reilly.

 

I would like to thank Andi Gutmans, Zeev Suraski, and Marcus Börger for their work on the Zend Engine 2, the core of PHP 5. I would like to thank Derick Rethans for Xdebug, the PHP extension that makes PHPUnit's code-coverage functionality possible. Finally, I would like to thank Michiel Rook, who wrote the PHPUnit tasks for Phing.

 

相关文章推荐

使用 PHP 的 Phing 项目部署工具

讲述使用 PHP 的 Phing 项目部署工具来进行单元测试、项目部署。

PHPUnit袖珍指南-第三章 PHPUnit的目的

第三章PHPUnit的目的到此为止,我们只有两个对Array和内建函数sizeof()的测试。当我们开始测试大量的array_*()函数时,每个都需要一个测试。我们可以每个都从头写起。但是,更好的方法...

PHPUnit袖珍指南-第一章 简介

很长时间里,我对“你什么时候会为PHPUnit写一个文档”这个问题的回答是:“你不需要PHPUnit文档,去读读JUnit文档或买一本Junit的书,试一试用PHP和PHPUnit来重写Java和Ju...

PHPUnit袖珍指南-第二章 自动测试

第二章 自动测试 最好的程序员也会犯错误。好程序员和差程序员的区别在于:好程序员能通过测试尽可能的发现错误。你越快测试错误,你就越快发现它们,发现和修正的成本就越低。这解释了为什么只在软件发布前才测...

PHPUnit袖珍指南 第十二章 测试的其他用途

一旦你开始写自动测试,你就会想要发掘更多用途。以下是一些例子。   12-1. 敏捷文档 通常来说,在采用敏捷方法作为开发流程的项目中,如极限编程,文档很难和迅速变化的项目设计和代码...

PHPUnit袖珍指南 第十章 代码覆盖率分析

第十章 代码覆盖率分析 你已经学会了怎么使用单元测试代码,但你怎么测试你的测试呢?你怎么发现没被测试的代码,换句话说,没被测试覆盖的代码?怎么衡量测试的完整性?所有这些问题的答案就是代码覆盖率分析。...

PHPUnit袖珍指南 第八章 未完成测试

第八章 未完成测试 当开始书写新的测试用例类时,你也许想要从空的测试方法开始,譬如:        public function testSomething( ) {        } 我们...

PHPUnit袖珍指南-概述

概述 聪明的Web开发人员会告诉你,越快找到代码的错误,你就能越快修正它,长期而言,项目成本越低。好了,能最有效的检测PHP代码中的错误的工具是PHPUnit,一个开发源代码的框架,它在你不在的时候...

PHPUnit袖珍指南-第五章 命令行测试工具

第五章 命令行测试工具 PHPUnit命令行测试工具是通过phpunit命令调用的。如下代码显示如何通过PHPUnit命令行测试工具运行测试。 phpunit ArrayTest PHPUnit...

PHPUnit袖珍指南 第六章 装置器

第六章 装置器 编写测试最耗时的部分是边编写设置整个程序到达一个已知状态,而后在测试结束后返回到原始状态。这个已知状态叫做测试的装置器。 在例5中,装置器很简单,只是存储在变量$fixture中的...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:PHPUnit袖珍指南-第一章 简介
举报原因:
原因补充:

(最多只允许输入30个字)