You are currently browsing the Test Me posts tagged: phpnw


PHPNW11

Slides for my talk “Are Your Tests Really Helping You?” are now available on Slide Share.

As presented at PHPNW11 in Manchester, UK.

PHPUnit Coding Standard: https://github.com/elblinkin/PHPUnit-CodeSniffer
(P.S. I owe tons of documentation and a few “removal of assumptions”)

BTW: #PHPNW11ROCKS

Preview: A Unit Testing Standard

As I mentioned in the last blog post, , I have been playing with PHP_CodeSniffer, and I have devised a standard for assessing the cleanliness and efficiency of the PHPUnit tests that are supposed to be unit tests.

If your unit tests pass this standard, then your tests should have taken less time to write, will take less time to debug, and there will be less time spent maintaining because everything in your tests would be perfectly straight-forward and pretty much prove that your interfaces for the code under test are simple to use as there would be no funny business need to prep those objects in your test code. This standard will be part of the tool set I will be presenting at PHPNW, so I will begin unveiling it.

Currently, there are about a dozen things in the standard to sniff for in your unit test code:

  • Filename Suffix Must Be Test.php
  • File Must Contain Class with Matching Name
  • Test and Provider Functions Must Be Public
  • Unused Data Providers
  • Class Must Extend Trusted Test Case
  • File May Contain Only One Class
  • No Interfaces
  • No Private Methods
  • Only Allowed Function Overrides
  • Public Functions Must Be A Test or Provider
  • Cyclomatic Complexity of 1
  • Nesting Level of 0

Some of these could probably be used on non-unit tests, but since unit testing tends to be the simplest, cheapest, and most scalable with a growing workforce and codebase, let’s stick with talking about unit tests.

PHPNW 2011

If you can make it to Manchester, UK for October 7-9, 2011, then you should consider coming to PHPNW 2011. Buy tickets here.

The schedule looks fantastic. Sebastian Bergmann and thePHP.cc will be there. Also, from my limited experience with this conference so far, Lorna Mitchell and crew run a very tight ship, which has left me even more impressed and excited.

I am very excited to say I will be also be speaking at PHPNW

Are Your Tests Really Helping?

Developer testing can reduce debug time, serve as executable documentation, build confidence, expose questionable patterns running rampant in your code, and in general, increase the speed of development and deployment. Tests can also cost you time, sanity, and agility.

This session will not be the same old re-hash of the Misko Hevry talk on testability. Instead of a talk that is generic, syntactically translated from Java to PHP, and neglectful the major coding patterns prevalent in existing PHP 5 code bases, all of which results in the majority of the audience as un-sold, we will look at coding and testing patterns inspired by a real PHP project. We will also discuss how to identify patterns and make small adjustments where testing is and is not helping. The end result will be a toolbox of habits we can use to improve testability and forward momentum in development.

I do honestly appreciate the gold standard talks on “Clean Code” (“Thank you, sir”), but those talks are nearly four years, if not more, old.

PHP is the driver of websites that touch millions, if not hundreds of millions, of users, and it is about time everyone stops doing the same-old hand-me-down presentations outside of a new hire training or a college classroom, and I’m tired of it.

I will try my best to give a great talk that can leave the crowd excited to go home and re-assess what is and isn’t working in the production of his PHP product and where to go from there.

Now, back to writing a less promotional blog post.


Tags