[wp-hackers] Unit Testing, Yet Another Discussion
jacobsantos at branson.com
jacobsantos at branson.com
Thu Aug 2 14:41:12 GMT 2007
Thanks Sam,
I really don't think that should deter unit testing. If enough people
get started then it will be easier for others to add, modify and improve
upon existing tests. At this point, a developer doesn't see anything in
the repository, and most of the research online brings up only
discussions about probably, maybe, sort of not ever doing it for WordPress.
I don't know when I'll be giving up. I'm finishing plugins.php, which is
easier, and I might jump over to cache.php and post.php (which I think
is more difficult), since I've had some tests for that already. If you
start out with the most difficult, then yeah, it will be depressing and
the more depressing something is, the easier it is to give up.
Preventing regressions in return values, is my main concern and
something that should be prevented by unit testing, both the easy and
more difficult functions (which are more likely to be updated).
It would be a good idea to test the hooks actions and filters. Creating
a contained and live work flow is worth investigating.
My goal is to get >95% code coverage on the easy files first and try to
get about 20% through 30% on the more difficult files for the unit tests
of wp-includes.
I'm also going to try to do some functional testing (acceptance
testing). I need a project to get started on learning how to do
acceptance testing, and I think WordPress is a good choice, because I
use it everyday.
I'll be back with any results and post all unit tests that I complete.
At least in the future there will be something.
Sam Angove wrote:
> On 8/2/07, jacobsantos at branson.com <jacobsantos at branson.com> wrote:
>
>> #3 Has anyone else (besides the guy building the functional testing with
>> SimpleTest, which is massively incomplete) started or finished their own
>> unit testing suite of WordPress?
>>
>
> I started writing some tests with PHPUnit about a month ago, got
> halfway through wp-includes/formatting.php and gave up.
>
> There were a few reasons, the main one being that too much of the code
> is very tightly-coupled: unit testing it is impossible without an
> absurdly complicated harness. There didn't seem much point to only
> testing the easily-tested functions -- most of them are stable anyway.
>
> At this point I think there's more value in starting with higher-level
> interface testing:
>
> 1. Tests of WP APIs: "if I call `wp_insert_post` with a title of
> 'foo', `the_title` returns 'foo'".
> 2. Tests of the WP interface with, say,
> <http://www.openqa.org/selenium/>. Wasn't one of the summer of code
> people was doing something like this?
>
> It's less useful than it would be with complementary unit tests, but
> still, better than nothing. The coverage could be deepened with unit
> tests later on.
>
> Anyway, good luck. I took up learning Haskell instead; it's much more
> rewarding. ;)
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
>
>
More information about the wp-hackers
mailing list