如何启动 TDD/BDD PHP CodeIgniter

发布于 2024-11-17 01:23:00 字数 266 浏览 1 评论 0原文

我已经阅读 TDD/BDD 有一段时间了,但我一直不知道如何在项目中实现它。

这是我当前正在工作的项目的简化版本:
一个允许人们注册、发布旧书待售的网站。需要这些书籍的人可以搜索附近出售的书籍,并通过网站向卖家发送电子邮件。

这是由我作为唯一的开发人员在 CodeIgniter 中编写的。对于这种情况,您能告诉我具体如何进行测试吗?从哪里开始以及要测试什么。

我想做这个已经有一段时间了,我有点理解这个概念,但实际的实现却让我困惑,非常感谢!

I have been reading about TDD/BDD for quite a while now but I could never figure out how to implement it in a project.

This is a simplified version of the project I am currently working :
A website that lets people signup, post used books for sale. People that needs these books can search for books posted for sale close-by and send an email message to the seller via the website.

This is being written in CodeIgniter with me as the only developer working on it. For this scenario, can you please tell me how exactly would I go about testing - where to begin with and what would be tested.

I've been wanting to do this for quite a while, I kind of understand the concept, but the actual implementation eludes me, many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

讽刺将军 2024-11-24 01:23:01

我使用的最新版本的 CI 附带的单元测试器很差,它只是检查是否正确。

我发现这个有趣的项目似乎至少维持到去年:

http://jensroland.com/projects /toast/

也许有一些东西可以帮助您开始,也许在自述文件中 - 如果没有,这里是这个想法似乎源自的原始帖子。

http://codeigniter.com/forums/viewthread/76703

您可以首先检查您的模型带回一组预期的值。也就是说,断言“获取前 10 本书”实际上会返回 10 条记录 - 这意味着要建立一个测试数据库,并且能够随意建立(填充测试数据)和拆除该数据库。这有点束缚,但在 MVC 情况下,当从 TDD 开始时,它可能是最容易让您头脑清醒的。

TDD(即按此顺序开发测试/代码的想法)在创建您自己的类时最有意义 - 您可能将其视为典型 CI 设置中的“助手”。

The unit tester that shipped with the last version of CI I used was poor, it just checked true or not.

I found this interesting project which seemed to be maintained up to last year at least:

http://jensroland.com/projects/toast/

Maybe there is something there to help you get started, maybe in the readme files - if not here is the original post where this idea seems to have emanated from.

http://codeigniter.com/forums/viewthread/76703

You could start off by checking your models bring back an expected set of values. ie assert true that "get first 10 books" actually brings back 10 records - this means setting up a test database however, and being able to set up (fill with test data) and tear down that database at will. That is a bit of a bind, but in an MVC situation when starting with TDD it might be the easiest to get your head round.

TDD (ie the idea of developing test/code in that order) makes the most sense when creating your own classes - which you might think of as "helpers" in a typical CI setup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文