TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Cover your PHP legacy code with 1000 unit tests in just few lines of code

32 点作者 zavg超过 11 年前

6 条评论

jonstjohn超过 11 年前
This is a cool idea but seems fairly limited when you take into consideration the state of the resources used in your application. For example, if I have a method that checks the balance of an account, I may hit that method with an account with a positive balance, make a payment, then hit the method again and have a zero balance. The method might take an account instance and the same account instance yields two different results.<p>I realize that this may be an issue with a poorly written method or un-anticipated side effects, but with legacy code, that is often what you have to deal with.<p>Cool stuff, though!
andybak超过 11 年前
At first glance this appears vaguely similar to this for Django: <a href="https://django-test-utils.readthedocs.org/en/latest/testmaker.html" rel="nofollow">https:&#x2F;&#x2F;django-test-utils.readthedocs.org&#x2F;en&#x2F;latest&#x2F;testmake...</a>
segmondy超过 11 年前
Yeah, this will be great for a functional language. PHP functions tends to have side effects and their results often rely on variables outside of the function which means the tests will be wrong.
评论 #6412895 未加载
jaredmcateer超过 11 年前
Anyone know the minimum version of PHP this supports? I still have to support code on 5.2.4 :( I&#x27;d like to try and implement this when I get a chance.
评论 #6412045 未加载
saltvedt超过 11 年前
This look really cool! :)<p>How does it handle that time has passed since the recording of the test?
评论 #6411340 未加载
waps超过 11 年前
This is why unit tests suck. They are but a simple exercise in basic code interpretation. A computer can easily do it.<p>What you want to test is the interface of your module to the rest of the application and whether it satisfies the published contract, and preferably if it handles weird cases correctly.<p>Those tests cannot be done by a tool.
评论 #6411360 未加载
评论 #6411384 未加载
评论 #6411697 未加载
评论 #6411802 未加载
评论 #6411395 未加载