A unit test story
- From: Philip Van Hoof <spam pvanhoof be>
- To: tinymail-devel-list gnome org
- Subject: A unit test story
- Date: Sun, 20 Aug 2006 20:25:58 +0200
Dirk Jan recently sent me a patch that changed the iterator API. The
patch (from the outside) looked great. There where no changes (on first
sight) that where identifable as something that breaks existing code.
He told me the patch works perfect with his local copy. I tried his
patch. It didn't work for me. I didn't see folders in the demo-ui
anymore.
So I ran the unit tests and I noticed the _has_first method of the
iterator API never returned TRUE anymore. Not even if a list did have a
first element.
So what happened:
Dirk's cache folder has the folders already. An account being offline or
online will always show the cached folders.
I always remove my cache before testing patches. So I had to "go online"
to test the stuff Dirk had sent me. You know, to get the folders from my
IMAP service. If I'm offline, I will never get these. Right?
That button on the demo-ui invokes code in the framework that walks the
list of accounts and sets their online status to true. It does this
using an iterator (ahaaa, danger danger, alert!). It did this by using
the old walk technique: checking whether there's a first and if there's
a first, walk the accounts until there's no more next account.
But remember: the has_first didn't work. The unit test just told me
that.
So both the configured accounts of Dirk and my tinymail clients where
never truly set online. At Dirk, the accounts already had folders
cached. My client didn't have such cached folders. So I never saw any
folders: because the accounts where never set online (because the
has_first of the iterator didn't work). Dirk already had his folders
from cache. So he told me: everything works! Look! It works for me!
No it didn't, Dirk. It worked for you because you already had folders in
your cache.
Next time, and this isn't to accuse Dirk of something: lets make SURE
the unit tests pass before you guys send me a patch.
It DOES save time. Mine AND yours. It IS interesting information
(whether or not a unit test succeeds). You DO learn from the results
whether or not your patch actually does what it promises to do. It DOES
test whether or not you broke something.
DO use them. Yes DO use them. And DO make them. DO update them. DO run
them frequently. If you want to contribute to tinymail: I insist you do.
--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]