Automated testing with PHP
I'm a .net developer so pardon me for not knowing anything about PHP. I read some things on the net but I can't say how it compares to Asp.net MVC in terms of automated testing.
I tend to think that PHP is very much like classic ASP except that it's OOP (is it?). In order to improve its testability you have to follow certain development patterns and code style to provide SoC (similar to Asp.net WebForm where you have to do MVP for instance but you're still light years away from what Asp.net MVC gives you out of the box).
So. How does PHP compare to Asp.net MVC in terms of writing automated tests (most notably unit tests of course)? Do I have to use certain librari开发者_开发技巧es? Do I have to follow certain rules/patterns to make it work?
How about continuous integration? Can test be auto run there as well?
There are three that I use, depending on the situation: SimpleTest, PHPUnit, and Zend_Test (which is really just a wrapper for PHPUnit to be used with the Zend Framework). Of these, SimpleTest really is easier. However, PHPUnit provides a lot of power and flexibility.
I'm not a .net developer, so I can't compare the two, but I can help fill in a few gaps about PHP.
First, while PHP does support classes and OOP like you're accustomed to, it's not necessary. In fact, some PHP-based projects (such as Drupal) have little to no OO code in them.
As for testing PHP code, you'll probably want to use PHPUnit. It implements the xUnit system for testing code in PHP. But if PHPUnit isn't to your liking, then you may want to check out SimpleTest, a slightly different PHP testing framework.
php doesn't compare to asp.net mvc as php is a language like c# They both have OO and you can test methods and classes like you do in asp.net
Just like in asp.net you have a mvc in php too. You might want to take a look at some frameworks like Symfony that work on the same mvc model.
Testing in .net is done with NUnit or others, in PHP you have some simular ones like PHPUnit and in Symfony there is Lime too.
actually, I'm in the oposit situation comming from php and now in c# development, and it's all almost the same...
tests can be autorun, in .net you might know nant (automated testing and build tool), ant is the same for php/java and hudson as a tool to get an overview on all builds.
精彩评论