Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!



翻译自 http://giuliodaprela.com/unit-tests-in-wordpress-an-introduction

这是我要写的 WordPress 单元测试系列文章中的第一篇。其实有人发布过几篇关于单元测试的教程,但是我没有找到 PHP 和 JavaScript 集中测试的相关内容,这就是我写这几篇文章的原因。

单元测试是软件开发的一个部分,越是复杂的项目单元测试就越重要,测试驱动开发 是一个必然趋势。 It’s all about making sure that your software behaves as expected, and keep behaving as expected even after you modify it to introduce new functions, improve it, fix bugs etc. It’s frequent the case where a developer introduces a new feature in a plugin, and inadvertently breaks something else in doing this, and only when clients report the bug realizes that. Unit tests should help you avoid this situations.开发者经常在为插件添加一个新功能的时候,难免因为疏忽造成其它部分问题,直到客户反馈之后才发现问题。单元测试可以帮助你避免这种情况,确保软件在改动之后仍按预期运行。