Brian Button - One Agile Coder

Blogging on all things .Net, C#, and Agile

My Links

Blog Stats

News

Archives

Post Categories

Agile Solutions Group

Blogs I read

Enterprise Library V1 Team

Story Telling with Programmer Tests

(First test post with Windows Live Writer Beta...)

Here are the tests for a class I wrote a while ago. This class is used internally by the Caching Application Block inside the Enterprise Library. It has a bunch of housekeeping data inside of it, but the only really interesting behavior in it revolves around determining when an item in the cache is expired. The user is allowed to provide zero or more objects who can determine, in a manner of their own choosing, whether or not the item in question has aged too long and should be flushed from the cache.

What I hope to show, and what I'd love feedback on, is whether or not these tests tell you the story of this class. This test class is named CacheItemExpirationsFixture, which I hope gives you, as the programmer and reader, a clue that I'm going to be talking about CacheItem's and how they are expired. And I truly hope that the names of the tests tell a progressive story about how this class was designed, what my intention was when I wrote each of the test methods, and would give someone else enough of a clue to be able to figure out which test to look at to learn something of interest about the class under test. 

namespace Microsoft.Practices.EnterpriseLibrary.Caching.Tests
{
    [TestClass]
    public class CacheItemExpirationsFixture
    {
	[TestMethod]
        public void CanExpireCacheItemFromSingleExpirationObject()
	[TestMethod]
        public void ItemShouldNotBeExpiredIfNoExpirationObjectIsExpired()

	[TestMethod]
        public void ItemNotExpiredIfAllExpirationsAreFalse()

	[TestMethod]
        public void ItemIsExpiredIfAllExpirationsAreTrue()

	[TestMethod]
        public void ItemIsExpiredIfAnyExpirationsAreTrue()

	[TestMethod]
        public void ItemIsNotExpiredIfNoExpirationsAreGiven()

	[TestMethod]
        public void ItemIsNotExpiredIfEmptyExpirationArrayIsGiven()

	[TestMethod]
        public void SingleExpirationIsNotifiedWhenCacheItemUpdated()

	[TestMethod]
        public void AllExpirationsNotifiedWhenCacheItemUpdated()

	[TestMethod]
        public void CtorForLoadingInitializesExpirationsToMatchLastAccessedTime()
    }
}

Now here is the body of one of the tests. It is short, declarative, and illustrative of the intent I had in mind as I wrote this test. All the tests in this class are similar to this, differing mostly in the details of what was being tested.

 

	
	[TestMethod]
        public void ItemIsExpiredIfAnyExpirationsAreTrue()
        {
            CacheItem cacheItem = new CacheItem("key", "value", CacheItemPriority.Normal, null, new NeverExpired(), new AlwaysExpired());
            Assert.IsTrue(cacheItem.HasExpired(),
                          "Any expirations in collection are expired, cache object is expired");
        }

Now, its entirely possible that some of the details of the context might not be familiar to you, but hopefully the basic idea is. I create my object, call one of its methods, and ensure that the right thing has happened. The test is short, complete in and of itself, and hopefully pretty descriptive of the what I was trying to demonstrate.

The reason I'm writing this is that I've been seeing a lot of tests lately that do none of the things that I've just written about. They have a generically written test fixture name, the names of each individual test method are short, like public void incrementCount(), and the implementation of the test is long, twisted, complicated, and totally unrevealing of the intent of the person writing the test.

I'm hoping that this post can serve as a jumping off point for me to start blogging about what it takes to keep tests telling simple stories, and for having the tests drive a simple, yet complete, design into the application code. I intend this to be a continuing series on this topic, as I feel quite strongly about it. In my mind, the ability to create simple tests, have those tests tell a compelling story, and have the test methods themselves be an expression of my design intent, rather than an example of a messy implementation, is the key to really getting TDD.

More (much more) later.

-- bab

posted on Monday, August 14, 2006 9:38 PM

Feedback

# Writing Unit Tests to Describe the Programmer's Intent 8/15/2006 7:57 AM Espresso Fueled Agile Development

Brian Button has a great post with an example on how to write descriptive unit test fixtures and unit...

# re: Story Telling with Programmer Tests 10/4/2006 5:10 AM merdi

http://www.kokoom.com/sexy-clip/adolescentes-chaudes-avec-cul-a-baiser-et-foufoune.html FTG1 http://www.kokoom.com/sexy-clip/amateurs-de-femmes-black-salopes-nue-sur-une-table.html FTG2 http://www.kokoom.com/sexy-clip/belle-lesbienne-blondes-nues-sexy-pour-erection-longue.html FTG3 http://www.kokoom.com/sexy-clip/bonnasse-baisee-et-amatrice-japonnaise-grosses-cochone-pour-massage-coquin-a-domicile.html FTG4 http://www.kokoom.com/sexy-clip/branleuses-bourgeoises-soumises-pour-videos-porno-x.html FTG5 http://www.kokoom.com/sexy-clip/chatte-contre-chatte-et-branleuse-de-bite-dans-sexs-films.html FTG6 http://www.kokoom.com/sexy-clip/chattes-beantes-rasees-de-collegiennes-bourrees.html FTG7 http://www.kokoom.com/sexy-clip/chattes-beurettes-en-chaleurs-et-cochones-nues.html FTG8 http://www.kokoom.com/sexy-clip/cherche-putes-a-paris-cochonne-exitante-pour-massages-erotiques.html FTG9 http://www.kokoom.com/sexy-clip/chiennes-nues-les-plus-belle-du-mondes-xxx-sex.html FTG10 http://www.kokoom.com/sexy-clip/club-echanchiste-pour-couple-amateurs-triolisme-echangisme.html FTG11 http://www.kokoom.com/sexy-clip/cochonne-femme-sexy-etlesbiennes-lesbiennes-pour-masturbation-branle.html FTG12 http://www.kokoom.com/sexy-clip/cochonne-libertine-coquine-pour-couples-mature-et-libertin.html FTG13 http://www.kokoom.com/sexy-clip/cul-sexe-de-jeune-salope-avec-grosse-chattes-pour-video-cul.html FTG14 http://www.kokoom.com/sexy-clip/escort-fellation-nature-et-ejaculations-interne-pour-18-ans-denudee.html FTG15 http://www.kokoom.com/sexy-clip/escort-girl-femme-mure-ou-filles-cochonnes-bouffeuse-de-bite.html FTG16 http://www.kokoom.com/sexy-clip/fellation-baveuse-de-grosse-garce-pisseuses-xxx.html FTG17 http://www.kokoom.com/sexy-clip/femme-en-petite-tenue-aux-gros-seins-pointus-pour-photos-masturbation.html FTG18 http://www.kokoom.com/sexy-clip/femme-mure-a-defoncer-et-chatte-en-chaleur-rousse.html FTG19 http://www.kokoom.com/sexy-clip/femme-qui-se-rase-la-chatte-et-partouze-celebritees.html FTG20 http://www.kokoom.com/sexy-clip/femmes-chaudes-et-grosse-chiennes-chinoise-pour-filme-porno.html FTG21 http://www.kokoom.com/sexy-clip/femmes-cubaine-nues-porno-avec-filles-de-18ans-depucelees.html FTG22 http://www.kokoom.com/sexy-clip/femmes-lesbiennes-libanaises-et-filles-saoudiennes-nues.html FTG23 http://www.kokoom.com/sexy-clip/femmes-mures-poilues-aux-gros-seins-gros-nichons-pour-porno-hard.html FTG24 http://www.kokoom.com/sexy-clip/femme-soumise-hardeuse-xxx-jouit-dans-orgasme-sonore.html FTG25 http://www.kokoom.com/sexy-clip/femmes-sexy-salope-lesbiennes-francaises-pour-film-pornographique.html FTG26 http://www.kokoom.com/sexy-clip/femmme-chaude-et-sadiques-baise-salope-dans-video-pornos-sexe.html FTG27 http://www.kokoom.com/sexy-clip/fesses-migonnes-de-fille-18ans-chiennes-et-salopes.html FTG28 http://www.kokoom.com/sexy-clip/filles-marocaines-virginite-grosse-salope-nue.html FTG29 http://www.kokoom.com/sexy-clip/filles-puberes-nues-avec-foufounette-et-masturb.html FTG30 http://www.kokoom.com/sexy-clip/filmes-de-sexe-avec-grosses-poitrines-et-petite-pute.html FTG31 http://www.kokoom.com/sexy-clip/film-porno-d-anal-sexe-et-gang-bang.html FTG32 http://www.kokoom.com/sexy-clip/foufoune-ouverte-et-foufounes-tres-chaudes-pour-amateurs.html FTG33 http://www.kokoom.com/sexy-clip/grosses-bites-dans-gros-vagins-de-cochonne-pute.html FTG34 http://www.kokoom.com/sexy-clip/grosses-cochonnes-j-avale-le-sperme-et-lolitas-depucelees.html FTG35 http://www.kokoom.com/sexy-clip/grosses-poitrines-blanches-videos-et-photo-de-femmmes-mures.html FTG36 http://www.kokoom.com/sexy-clip/histoire-de-fille-en-manque-de-bite-ou-jeunne-latina-xxx.html FTG37 http://www.kokoom.com/sexy-clip/infirmieres-suedoises-et-jeunes-salopes-espagnoles-nue.html FTG38 http://www.kokoom.com/sexy-clip/italienne-en-chaleur-et-pute-japonaise-escorts-sexe.html FTG39 http://www.kokoom.com/sexy-clip/jeunes-chattes-rasee-avec-piercing-pour-photos-artistiques-de-pubis.html FTG40 http://www.kokoom.com/sexy-clip/jeunes-lesbiennes-amatrices-pour-partouze-voisine-et-sexe-porno-stars.html FTG41 http://www.kokoom.com/sexy-clip/jeunes-mecs-beurs-dans-lieu-rencontre-gay.html FTG42 http://www.kokoom.com/sexy-clip/jeune-suceuse-queue-pour-penetration-et-rencontres-libertines.html FTG43 http://www.kokoom.com/sexy-clip/jeunne-nymphette-nue-et-filles-pervers-pour-porno-movie.html FTG44 http://www.kokoom.com/sexy-clip/la-grosse-pute-qui-baise-sur-video-x-jeunne-fille-suce-vieux-pervers.html FTG45 http://www.kokoom.com/sexy-clip/les-plus-belles-queues-pour-mal-baisee-nous-arrivons.html FTG46 http://www.kokoom.com/sexy-clip/maitresse-dominatrice-en-culotte-pour-grosse-baise.html FTG47 http://www.kokoom.com/sexy-clip/massages-sexuels-a-domicile-et-photos-bonnases-en-string.html FTG48 http://www.kokoom.com/sexy-clip/masturbation-de-penelope-film-pornographie-grosse-bite-.html FTG49 http://www.kokoom.com/sexy-clip/masturbation-et-sexe-photo-galerie-gratuite-sodomie.html FTG50 http://www.kokoom.com/sexy-clip/moules-jeune-lyceenne-libertine-cochonne-a-baiser.html FTG51 http://www.kokoom.com/sexy-clip/partouzes-chaudes-et-photos-sperme-plein-bouche.html FTG52 http://www.kokoom.com/sexy-clip/photo-de-chanteuse-en-petite-culotte-sexie.html FTG53 http://www.kokoom.com/sexy-clip/photo-de-femme-en-chaleur-et-petite-suceuse-aux-petites-fesses.html FTG54 http://www.kokoom.com/sexy-clip/photo-de-femmes-a-poil-dans-manga-sex-de-jeune-petite-salope.html FTG55 http://www.kokoom.com/sexy-clip/photo-erotique-site-porno-anal-de-mangeuse-de-bites.html FTG56 http://www.kokoom.com/sexy-clip/photo-gros-sein-salopes-et-videos-de-bonnases.html FTG57 http://www.kokoom.com/sexy-clip/photo-porno-hard-de-jeunettes-infirmieres-defoncees.html FTG58 http://www.kokoom.com/sexy-clip/photos-amateur-sexe-femme-punition-et-double-penetration-anal.html FTG59 http://www.kokoom.com/sexy-clip/photos-cochonnes-blonde-et-belles-femmes-sexys-xxx.html FTG60 http://www.kokoom.com/sexy-clip/photo-sexe-de-pute-sodomie-anal-et-salope-fellation-sperme.html FTG61 http://www.kokoom.com/sexy-clip/photos-grosses-queues-et-videos-positions-kamasutra.html FTG62 http://www.kokoom.com/sexy-clip/photos-institutrices-pornographique-et-pipe-de-jeunes-filles.html FTG63 http://www.kokoom.com/sexy-clip/photos-minous-vierges-et-video-vagin-gros-plan-sex-porno.html FTG64 http://www.kokoom.com/sexy-clip/photos-pornographiques-de-putes-sodomies-et-fellation.html FTG65 http://www.kokoom.com/sexy-clip/photos-sexe-porno-de-pute-salope-qui-se-fait-baiser.html FTG66 http://www.kokoom.com/sexy-clip/pornographie-grosse-bite-et-salopes-americaines.html FTG67 http://www.kokoom.com/sexy-clip/putain-de-baiseuses-a-petites-chattes-grosses-bites.html FTG68 http://www.kokoom.com/sexy-clip/pute-a-blonde-pulpeuse-et-salope-chienne.html FTG69 http://www.kokoom.com/sexy-clip/putes-etudiantes-salopes-et-sexe-avec-chattes-puberes.html FTG70 http://www.kokoom.com/sexy-clip/recit-de-baise-en-couple-et-recontres-sexuelles-avec-salopes-et-bonasse.html FTG71 http://www.kokoom.com/sexy-clip/regarder-miniclip-sexe-avec-salope-et-grosse-chienne.html FTG72 http://www.kokoom.com/sexy-clip/rencontre-chaudes-avec-salope-bien-juteuse.html FTG73 http://www.kokoom.com/sexy-clip/reunionnaise-nue-photo-porno-dans-video-de-suseuse.html FTG74 http://www.kokoom.com/sexy-clip/salope-a-domicile-collegienne-defoncee-bite-pour-ejaculation-grosses-bites.html FTG75 http://www.kokoom.com/sexy-clip/salope-asiatiques-pour-sperme-ejac-chaude.html FTG76 http://www.kokoom.com/sexy-clip/salope-en-photos-pour-sexe-porno-et-soiree-echangiste.html FTG77 http://www.kokoom.com/sexy-clip/salopes-a-baiser-19-ans-avec-belles-chattes-porno.html FTG78 http://www.kokoom.com/sexy-clip/seins-et-fesses-nus-pour-ejacultaion-et-sperme.html FTG79 http://www.kokoom.com/sexy-clip/seins-et-fesses-nus-sexies-de-salope-baiser-perver.html FTG80 http://www.kokoom.com/sexy-clip/sexe-amateur-attachee-liee-corde-foulard-menottes-clitoris-orgasme-chaine.html FTG81 http://www.kokoom.com/sexy-clip/sexe-cochonnes-suceuses-bite-salopes-gratuit.html FTG82 http://www.kokoom.com/sexy-clip/sexe-cul-anal-fellation-ejaculation-et-sperme-culotte.html FTG83 http://www.kokoom.com/sexy-clip/sexe-images-de-salopes-en-collants-et-putes-hardeuses.html FTG84 http://www.kokoom.com/sexy-clip/sexe-live-femmes-nues-direct-et-webcam-girl-amateur.html FTG85 http://www.kokoom.com/sexy-clip/sex-movies-avec-jeune-bombe-18ans-et-suceuse.html FTG86 http://www.kokoom.com/sexy-clip/site-perso-amateur-sexe-porno-et-petites-cochones.html FTG87 http://www.kokoom.com/sexy-clip/soiree-etudiante-baise-chaude-avec-jeunes-lesbiennes-nudistes.html FTG88 http://www.kokoom.com/sexy-clip/stares-du-porno-en-string-bandante-bonnasse-et-chattes-velues.html FTG89 http://www.kokoom.com/sexy-clip/suedoises-a-sodomiser-et-belles-chattes-indiennes.html FTG90 http://www.kokoom.com/sexy-clip/suseuse-de-bites-et-petasses-en-chaleurs-pour-massage-sexuelle.html FTG91 http://www.kokoom.com/sexy-clip/tchatche-pute-ou-femmes-vierges-pour-baiser-une-salope.html FTG92 http://www.kokoom.com/sexy-clip/travesti-photo-recherche-jeune-homme-et-couple-pour-baise-a-trois.html FTG93 http://www.kokoom.com/sexy-clip/tunisienne-succeuse-pour-photo-branlette-espagnol.html FTG94 http://www.kokoom.com/sexy-clip/video-porno-de-jeunes-salopes-et-de-pipe-ejaculation.html FTG95 http://www.kokoom.com/sexy-clip/videos-casting-filmsx-avec-actrices-italiennes-nue-images.html FTG96 http://www.kokoom.com/sexy-clip/vieille-cochonne-en-chaleur-baise-lesbienne-90d-de-poitrine.html FTG97 http://www.kokoom.com/sexy-clip/voyeur-amatrice-adolescente-en-string-et-petite-culotte.html FTG98 http://www.kokoom.com/sexy-clip/wallpapers-de-bonasse-et-webcam-live-show-amateur.html FTG99 http://www.kokoom.com/sexy-clip/xxx-saloppe-pute-cul-et-prostituee-baisant.html FTG100

Title  
Name  
Url
Spam Protection:
Enter the code you see:
If you can't read it, click your refresh button to get a new image.
Comments