TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

32 pointsby zavgover 11 years ago

6 comments

jonstjohnover 11 years ago
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!
andybakover 11 years ago
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>
segmondyover 11 years ago
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 未加载
jaredmcateerover 11 years ago
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 未加载
saltvedtover 11 years ago
This look really cool! :)<p>How does it handle that time has passed since the recording of the test?
评论 #6411340 未加载
wapsover 11 years ago
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 未加载