2

I am starting work on a personal project which should (hopefully) develop into a startup, the project will need to scale well and I would prefer to invest the time now in TDD.

I am a big Lithium fan, and I am aware that Lithium have their own built in test suite, but I can't find any solid documentation on it and I have never done any real TDD before.

Is there a better way for me to go? Or should I just stick in with Lithium and grind the learning process?

EDIT: Just to clarify. I am talking about PHP Frameworks, not testing frameworks.

tereško
  • 58,060
  • 25
  • 98
  • 150
GaryDevenay
  • 2,405
  • 2
  • 19
  • 41
  • you tagged your question with mvc, maybe you are interested in using HMVC (instead). for tests phpunit is what most users use. for projects http://www.jenkins-php.org is a nice info page. – Hajo Apr 18 '12 at 23:25
  • There's not much to tell. Pick a testing framework of your choice, write your tests, then write your code. – netcoder Apr 18 '12 at 23:25
  • I'm more talking about PHP frameworks with integrated testing suites. Rather than using something like PHPUnit etc. – GaryDevenay Apr 18 '12 at 23:34

3 Answers3

2

Well, if you do plan on developing it in Lithium, then I would definitely stick with the integrated testing framework that's built into lithium.

Find it here:
http://li3.me/docs/manual/quality-code/testing.wiki

If you want to figure out how to integrate tdd into your normal development, I would recommend you pick up one of the .net mvc books by Steve Sanderson (since you seem to do a bit of .net already).

It should only take a few days of working though that book for you to get a solid understanding of how to integrate tdd into your development routine, since that book heavily emphasizes unit testing in development.

Good luck with your start up.

botero
  • 598
  • 2
  • 11
  • 23
ton.yeung
  • 4,793
  • 6
  • 41
  • 72
  • @GaryDevenay A video made especially for you, 2 years ago, for TDD with Lithium: https://vimeo.com/10697309 – Mehdi Lahmam B. Apr 19 '12 at 07:22
  • Yea, I've watched that. It did provide some good information but not nearly enough to develop a full blown application using TDD – GaryDevenay Apr 19 '12 at 12:35
  • 1
    Lithium can do unit testing... I'd go with something like Behat + Mink to do higher level tests. – greut Apr 19 '12 at 13:15
  • 1
    Lithium has been designed to make things testable and limit global state (or at least allow tests to set state as needed). The reason they wrote their own testing tools was they found PHPUnit to be a bit too slow and memory intensive for rapid TDD. In addition to what's already been posted, this blog post a few more notes for testing with the framework - http://nitschinger.at/Understanding-the-Lithium-Router-Part-2. – rmarscher Apr 22 '12 at 03:26
2

If you think, that your project might actually grow into something large, you should write it without the use of framework. The problem with frameworks in general is that they are made with "everything and a kitchen sink" methodology.

You would be much better off, if you build it all from scratch (maybe borrowing some parts you like from Lithium) and use PHPUnit as your testing suite/framework.

Also, i would strongly recommend watching this lecture (and maybe some others from same series), for some general pointers.

tereško
  • 58,060
  • 25
  • 98
  • 150
  • Would you then recommend that I build a purpose made MVC framework to fit only the needs of my application? – GaryDevenay Apr 19 '12 at 10:33
  • @GaryDevenay , no, the "framework" will emerge as you write your application, if you follow the OOP principles – tereško Apr 19 '12 at 11:15
  • But I would still need to write my basic MVC base which will format my requests and routing? Or are you recommending I don't develop it using an MVC pattern? – GaryDevenay Apr 19 '12 at 12:26
  • You do not need a *canned* framework to use MVC. And you do not need to write all from scratch. You can take the routing mechanism from the Lithium, if you like it .. or some other framework (only rewrite it a bit so that it does not relay on global state). – tereško Apr 19 '12 at 14:36
  • I don't agree that using a framework is bad. Yes, they generally come with everything imaginable but that is what makes them so useful for quickly deploying projects. They also come with community support which makes problem solving infinitely faster, since everyone involved is already familiar with the bones of your project. If you've got time and dont mind jumping hurdles alone then building a framework from scratch is wonderful (I've done it, learned a ton) but if you need fast turn around and support a community framework is always a win. – joseym Apr 21 '12 at 00:39
  • @joseym , but he does not need to write a framework. And if someone is serious about doing TDD then most of PHP frameworks will severely hinder that, 'cause of all the global state and procedural code they use. Also , just because you have a larger community, does not make it a smarter resource .. case and point: jQuery. – tereško Apr 21 '12 at 06:08
  • @joseym , you might find this article interesting : http://edorian.posterous.com/how-i-judge-frameworks-or-let-me-code-in-peac – tereško Apr 22 '12 at 10:34
  • @joseym, I think its easier to debug (and solve an issue) if code is yours wrt other's code and huge community who has not even contributed to framework. – Rahul Prasad Mar 12 '13 at 11:48
0

Have a look into Zend framework. It's one of the biggest and most comprehensive frameworks out there. Also it embraces MVC be default.

It also has a built in support for PHPUnit using Zend_Test.

Songo
  • 5,618
  • 8
  • 58
  • 96