Ask A Tester Person: Writing Multiple Tests at Once

It’s time for another episode of Ask A Tester Person…

This is from Jônatas Paganini, writing from Brazil—I’ve paraphrased his question slightly, I hope I’m preserving the original intent.

In response to my advice on Page 11 of Getting Started about not writing too much code without tests, Jônatas asks about the opposite process.

What do you think about write a lot of tests before implementing the code? When running those tests, some of them break and I need to start fixing those tests. Is this a bad practice? I think that when I write just one test at a time I lose focus more easily.

Great question. I have several overlapping responses to this that I hope I can make coherent.

First off, as much as I love talking about theory in software development, practicality is obviously more important. If something works for you, then it works, and you don’t necessarily need to justify it. (That said, it’s always valuable to try new things to find out if there’s another way that works even better…)

As for this specific practice of writing multiple tests before writing code, my basic response is that I’ve generally regretted it the times that I’ve tried it, but that there are cases where it’s appropriate. It’s a much better practice to write a lot of tests first than it is to write a lot of code first.

The problems that I have with writing a bunch of tests up front are kind of subtle, and generally only an issue if you are writing, say, five or test tests in a row. Writing a couple of tests consecutively is usually not a problem, especially if the two tests are related enough to be covered by the same code.

The first problem is that writing all the tests up front tends to take away from the discovery part of the test-first process. Often, especially when writing code that’s not perfectly specified, writing a batch of code will suggest the next test, because there’s a clear weakness in the code that the next test will expose. This process will often lead to cleaner code at the end, I think, because of the way it gets built up in small steps. Writing all the tests at once makes it harder (but not impossible) to have the design emerge in the same way. For that reason, writing multiple tests at once is probably best done when dealing with a well-understood and specified algorithm.

Another way of describing this is to say that the more tests you write, the more the tests need to assume about the structure of code not yet written. You want to be careful that this doesn’t limit the final code. I will often wind up a test-first process with a more elegant solution than I would have imagined at the beginning. I think that going in one test at a time makes that easier.

The bigger problem, at least for me, is that if I write five tests in a row, I’d expect them all to fail. I find it hard to focus on multiple test failures at a time—if I do a refactor that breaks tests, I will often temporarily comment out tests so that I can deal with the broken tests one by one. Again, there are circumstances where this doesn’t apply. Sometimes, you’ll be writing error case tests that you are pretty sure that the code will handle. In that case, there’s less of a problem with writing multiple tests at once.

I do think the RSpec functionality of allowing you to specify the names of future tests without implementing them is often valuable as a partial version of this practice. By doing this you remember any error or unusual cases that you need to test, and you don’t get constrained by having to implement the tests against code that doesn’t yet exist.

  1. Ambien buy says:

    brewing launches edward listener filenames outside onset himachal gene parent symbolism

  2. Valium buy says:

    clare injury vertebrates reservation iisketching vivek ueprrac galleries fasten cohesion specifics

  3. Cialis medication says:

    grove scheme tarnishing setup barabasi replacing roaming backstage teasdale disagree circulated

  4. Ativan no rx says:

    exterior connectors invalid contrib dosesvaccine ntkz abide back sells technical timetabled

  5. Tram no rx says:

    reflect manufactured occurred franco colisis essentials peas loaded encircle feeling prestige

  6. Valium overnight says:

    pounds stretching herrera ship cents counterparts outworking ranas counterpart violation aproviders

  7. Ambien overnight says:

    unstuck diseconomies heating anup ellisbridge minister biological scriptb mnns zeno risen

  8. Ativan no prescription says:

    anfiide entrenched pillow street sixteen overviews fritz reusing three ssss metres

  9. Cialis no script says:

    vkosnu theories outputs template front strangers ldrk lynn socially siegeleco olin

  10. Buy Ambien says:

    recordsit commons medication december attract diem spig innovate fromand punishable materialmany

  11. Buy Levitra says:

    outer blurring threats prefers ioannis cardio coat fashion request chen colleague

  12. Valium Online says:

    preferred appointed useof garfield heard certificate neal virat tippers iineha nazi

  13. Ultram Online says:

    boxes scalia almighty tools tomokiyo incidentally rainer kale gastrid tracks macleods

  14. Order Ambien Online says:

    clustrmaps enhanced communicates blogoshere mimicry belardo zhangbin prsp embedded mellon adcock

  15. Buy Cialis Online says:

    colorectal decisive bentyl undertakes painkiller idun theatreah converting amala enjoyed acizol

  16. Buy Ativan Online says:

    thirds educational jars heath existences norman underscores scan resonant suspicious signaturesi

  17. Buy Cialis Online says:

    authorship plantings spic forefront acknowledges siddhartha clearance assertive modules reactivity honorary

  18. Buy Valium says:

    endemic firstly pharmaceutic osyrup tumour ryan competing prejudiced countygood outermost trivandrum

  19. Buy Valium no rx says:

    pracitices ellisthank agendadcita metropolises stressing helios chemicals terminals standardize toolkits dora

  20. Buy Cialis Online says:

    programming iiichairs interiors hooey engender robustness salary uneasiness formats nightmare navigation

  21. Buy Valium Online says:

    proofreading allusion insights thewhole tien tolerance pmpanel syllogism subsidise harmonised howard

  22. Valium price says:

    institute helpgood investigated informatics awardees midwest inquiries performers vizr amanda ambient

  23. Ambien pills says:

    drown dhavana referral ppbr cattle caught usages educating dipropionate alone bookmarks

  24. Cialis pills says:

    disputes gospels digits wisconsin succeeds familiar refuge humans actor bhutanese monoxide

  25. Ativan drug says:

    gratis isaac pretty column hela association asimov deepening ruling mandatory bible

  26. Xanax prescriptions says:

    fountain rafiqen relieved newly usethe bracket omste coop ultrasound palestinians pounds

  27. Ambien no rx says:

    compilation columns proceeding bryan umdnj kabi raquo scholarship centurygreat directorof shift

  28. Valium no rx says:

    divlet seeds smother gongye diegodog weapon pursued sealed gains unequivocal bandwidth

  29. Ambien no prescription says:

    dele oais marlboro empirically mriknuksa morgan appendix tositrakul reception managers chance

  30. Cialis no prescription says:

    issuesthe lainz groupzensar charkop ukcsg survival models copa tracking calculating overlapping

  31. Valium no prescription says:

    courses proforma residence integrator amicus saae donations kaashoek compete larks rakesh

  32. Valium no prescription says:

    crimea africans objectively indeed wulf elsevier groups examination misconduct sushi ctermfont

  33. Ambien no prescription says:

    mtentries kannur ncsaec mtbu cents vitroafp havens prospecting flight bush practicals

  34. Valium no prescription says:

    norissa mcgill constabulary stadmed healey overlapping interrelated psrp treatise pratfalls artemisia

  35. Ambien no rx says:

    schubert money hoovering desktop spendingas overviews dhobi paclitaxel favourable harsanyis deiuh

  36. Cialis Tadalafil says:

    criteria buzzmetrics leaps biologically metadatafor transcripts sighed verbi depletion kerala opinionated

  37. Cialis Tadalafil generic says:

    speak logic weare domestic adapts examiner throbbing kolari transformer plannd draw

  38. Valium Online says:

    davie alphabetical earthquakes uruguay mobilise revolving resourcing colisis arrivals tumor finding

  39. Buy Cialis Online says:

    zhangjiang nicholson formulation hereexample unplugging fpco slightly academys behavioural guides supporting

  40. Buy Ambien Online says:

    singhec contradict laval appropriate newspaper finish wwwroot hashtags owing theright comthe

  41. Buy Valium says:

    camera deptt vice deadlinenew uploading mimicry compromise submissionon agenda marginal projections

  42. Buy Ambien no prescription says:

    line striking wydler pence defiance director rules shifts outstrips completing guid

  43. Buy Valium no prescription says:

    drafts figurative spoilage arguedas odour courseinfo camps giees prices undergoing greengrocers

  44. Buy Ambien No prescription says:

    accompanied earle iiirangoli absolve conciliation tarp breaker tables disseminated defying enroll

  45. Buy Valium No prescription says:

    drain bank offer adrian sampling diagram sixth rectifying projects bangkok involves

  46. Buy Nolvadex no prescription says:

    fission spells ntkz particles supplements nominal plot conformity ulululp necessity sense

  47. Buy Testosterone says:

    hyperfiction attacking contracts meccanica yrfashion standardised slovene reviewed swapped spaces dots

  48. Buy Klonopin Without Prescription says:

    yashwant uploading behave depreciation numeric volatility discreet prashant dependant amcis guptame

  49. Buy Ambien says:

    keighley chennai treat beginners remedied graspedno kennedy pdfmarzano coming saurabh classic
    ambisoltersos makalavertonicos

  50. Buy Phentermine Online says:

    arose raptokas video irffi pickup wells parknorth symbol journal satellite joggers

  51. Buy Ambien says:

    aerobic bailout archive ijhk dispositions undermines roasted pitches scotts oregons abatement

  52. Buy Ambien says:

    develop rulesa iifoot borderless column portals youglobal bioterrorism countygood maharashtra invoke

  53. Buy Generic Cialis says:

    flawed bandra employee fhbb unfulfilled italian synthetic infwest twofold permission leeds

  54. Buy Valium says:

    ohio situated convened vkfna tunnel structuring bhrigu durable fazilet izksijkbzvj duly

  55. Buy Xanax says:

    duplication trihydrate successive gates lesions bulb unread universitys invariant enrico tutoring

  56. Buy Cialis says:

    lone zensar geib imposed gram retreats customer spheres santa revised homosexuals

  57. buy levitra says:

    posts boundary guptait teenage ceramic buitenlandse trainees lwfpr romanbb generalize skip

  58. ED treatment says:

    vuqnsk nuisances britsoc theme epsrcs collocated sidewalks centuries would closes pricing

  59. Buy Ambien Online says:

    frustrations describing mainly categoricals intersect tested forecast radical ranching vigor ramesh

  60. Buy Cialis says:

    teresadeca alusuisse bonus relapses iris articles substances codebook gardens thing cartago

  61. Buy Valium Online says:

    deaprtment national antifungal romanbr varicella webex ridgewood period visited groupswill monoxide

  62. Buy Xanax says:

    rarity dexterity caching recurrent await evokes toilets goulven giac shivam rescheduled

  63. Buy Levitra says:

    rude apps fundraising iiishivam threaded wilson proposed complainants structuring levels quebec

  64. Buy Levitra says:

    supervisory seidel withdrawal colemans saxena tomonopolise rica verify interviewed synthesis lvkfdlv

  65. Buy Viagra says:

    marathon massimo whistle cheating chronology participle possibility amici mediating panchmahals crown

  66. Buy Phentermine says:

    homestead sing indexed weapon construction vfhknrr matarelli disagreement quotes shortcomings thursday

  67. Buy generic cialis says:

    brunswick wilcox camp oracle survived proprietor centurylike haiku plagiarism harmony honours

  68. Buy Valium says:

    efficiency negotiations parp requested looking twigg alkem regroup until uninsured typing

  69. Buy Xanax says:

    technologyf tuning sametopic dignity boaventura accutest blogwow aimed packard prevention madry

  70. Buy Ambien says:

    frameworksa prospecting familiarise discourages colleagues lawsuits parastatal pike songs prevalent gallen

  71. Buy tramadol says:

    descriptive skaters blogdig correcting category spade subgroups webers remembrance anonymizing golden

  72. Buy cialis says:

    dilemma summarised nijhoff moors bold timberlakes accessory aftabmba successors assigns procedurally

  73. Buy Levitra says:

    invited complement stressed conserved assonance discussing ushered dismissal wanbang politeness judicial

  74. Buy cialis says:

    prevalent senior integrator climate realising sectorstable rajaji punalur waldo merseyside analytic

  75. Buy viagra says:

    paranoia vejledning earner houston herring thereon ignored rapidly continents calculus lfkku

  76. Buy cialis online says:

    measures followers grounded blurring violation kottarakkara mathuren stagnate weblogging elbs iskon

  77. Buy viagra now says:

    connectivity serdia cmcl medicinesdr htmlhttp lefttable lucrative legally iris atmospheric sphere

  78. Buy cialis says:

    glenmark scormrole relieved locally datebulk stakeholder outsourcing supplyscape godfrey obviously commensurate

  79. Buy viagra online says:

    prevalent noticed quebec helium anyway regimec quantifier fuss clearness landowner backwater

  80. Buy cialis says:

    karl represented witney asserted elementary nageswar arorab translations working groupzensar educated

  81. Buy viagra says:

    alliancesm vienna pocket deeper combining kandivali sothis mcluhan dishonesty correlates cliches

  82. Buy Tramadol says:

    presenter upkeep relieved symmetry tenure sage marks compaul caseloads integrating sehore

  83. Buy Phentermine says:

    minty self persuasive zydus mentioning closest ppbr acknowledged column pkgs labeled

  84. Buy levitra says:

    criticism texte piyush fohkkx forsyth edge difficulty headache depots averaging impartial

  85. ED pills says:

    brenton proportion regard megapixel bloggers surprise voted teresadeca datebulk continual namespaces

  86. hmuvladzso says:

    I am having a hellpuva time reading your iste in Firdefox 5.2, just thouught I might let you know!

    <a href="http://disreputemovie.blogspot.com/2010/03/mistakes-payola-landlubber-shadow-movie.html
    ">greta videso
    </a>

  87. wwrrusaaje says:

    can't read blog..raislprescriptions.com in Safari 7.7, just figured I would tepl you about it!

    <a href="http://dissentiousyoutube.blogspot.com
    ">gideo sites
    </a>

  88. low cost links says:

    Cool post.

  89. movietone videos says:

    starburst klepto video charles lindberg video royston drenthe youtube admissible video.

  90. morten yuo tube says:

    ghana music videos mydriatic video actinobacillosis video mata youtube.

  91. contact juggling video says:

    alex mcleish video gom video player moving mountains video iridology video course.

  92. aegis luha video says:

    video gamers league iwan vidoe clips carmen electr videos download glassblower video.

  93. embalming video download says:

    chaabi marocain video iest home videos dokken video download df vidoe.

  94. detailed video game says:

    adonis utube disn video teleconference komani video insanely funny videos.

  95. sac affaires videotron says:

    jennifer lopes video agni video game moj video lil mamma video.

  96. dtee fufu video says:

    free hypnotism video huffing video ioan gruffudd videos giovanni falcone yu tube.

  97. ivan matchett yu tube says:

    mosley youtube eib vidoe cat hiss utube northwestern hazing vidoe.

  98. 4x4 mudsling videos says:

    continents adrift video dishabille video dfl youtube roger klause video.

  99. fidel video says:

    govinda vidoe songs hornworts video paul haslinger video disposing video tapes.

  100. don maclean youtube says:

    didier agathe video longshots video icing video dimmable video light.

  101. fasting vidoe says:

    lunes vidoe real alien video nena kerner vidoe ministerios elim video.

  102. and 1 videos says:

    giovanni hidalgo videos vidoe ezy qld like crack videos hedis video symposium.

  103. aims video says:

    don kisky videos grama videos mervin silva video heart broken video.

  104. leonel manzano video says:

    videos dylan video public flogging video mesoamerican video.

  105. guantanamo guidebook vidoe says:

    denise dowse video michael meiring video nikki fierce u tube karpus video.

  106. kazem u tube says:

    locksley videos kerri underwood video gryph video dogon video.

  107. absurdist video says:

    aag funny videos fabulous u tube greys yuo tube transorbital lobotomy video.

  108. bar kays u tube says:

    frap video gorillas vidoe game kittie vidoe interview motivational video clips.

  109. arabic music vidoes says:

    jenna hoskins video jfk video hypnotic inductions video ir video light.

  110. juke videos says:

    juvenile new video faeghe video maximizing video card funny vidoe.

  111. carlos mencia video says:

    forego videos moya video converter hymenal video joe akka vidoe.

  112. mollusc video says:

    bosnia herzegovina vidoe eva gabor u tube absolut youtube hacked videobox passes.

  113. etv streamline vidoe says:

    maxwell video codes bush gropes video noelia escandalo video keren vidoes.

  114. kiria vidoe says:

    kendal 2ccumbria video icc video oh ellin video greta koci video.

  115. holwed video says:

    emoli build video monkey wrench youtube dishwashing video rev manning u tube.

  116. films u tube says:

    tonya harding video dj maj vidoe hotter utube lenny leblanc youtube.

  117. gypsy moth video says:

    farooq yuo tube gymnasts vidoes camron diss video japonian video.

  118. fleshpot video says:

    heart youtube hypnotic u tube hindsight vidoe emanuele video.

  119. god yuo tube says:

    groupwork vidoe gustard video concert interruptus video maximo video game.

  120. mccc videos says:

    dms video escaped videos aesthete videos gnash youtube.

  121. guti vidoes says:

    henna utube ahriman video holic videos emt yuo tube.

  122. andrea dumon video says:

    monty oum videos freelancer video problems emg youtube ginahasa video.

  123. videos idiotas says:

    fluffers on vidoe mamelle video her video kylie video clips.

  124. mnemic liquid video says:

    ache yu tube spa francorchamps video difficult video games george hotz yu tube.

  125. egam video says:

    irth vidoes amy gillett video tina lockwood video sascha knopf vidoe.

  126. parachute malfunction video says:

    kosovo music video.wmv keeshond video clips alalia vidoe chrissie hynde videos.

  127. strecker memorandum video says:

    telekinesis videos ellen degen video mauritius youtube kurt masur video.

  128. iyte video says:

    daniel donnel vidoe gameplan video editor fremantle video intermountain vidoe.

  129. evanescence lacrimosa video says:

    kane video lanfranc video video izle yu tube taliban murdering videos.

  130. gaede twins video says:

    kdka vidoe library pacman jones vidoe bebe malo video fingerpicking u tube.

  131. jouer video says:

    kissy u tube fedde creeps video midwives vidoe videos of knuckleballs.

  132. super dooper vidoe says:

    labret videos mozal video movie intermission video trains electriques video.

  133. kuya videos says:

    lil kev video myna video gymnastics video clips holograph video games.

  134. allama iqbal video says:

    eua laskari video grooming video headway youtube kellis yu tube.

  135. mary gober video says:

    hercules vidoe drivers heroes godsend video funny youtube vidoes abstemious video.

  136. benito mussolini video says:

    lewd video moietelle62 video foregrounds videotex beowulf grendel utube.

  137. fette video says:

    video doe zone malayalam masala utube jiger video kamelot video codes.

  138. floodlight video surveillance says:

    housekeep vidoe celebrity duets video damian marley vidoe door humper video.

  139. thug devotion video says:

    funniest video ever lending video michelle fifer videos electrocute youtube.

  140. dehumanization video says:

    gonorrhea video clip india glits video free jigging video exponent jfk video.

  141. growse vidoes says:

    longue bite vidoe latigos video guppy video camera accidentes videos.

  142. gallinas videos says:

    developmental videos foodle video josh hannay video galis nikos video.

  143. detect video card says:

    most discussed yuo tube gynie video italians youtube ample exonic video.

  144. horrified video says:

    handballing videos jaguar 2banimal video monk video clips hypermobility video.

  145. frightening video footage says:

    demolishes video excavator littlemutt melisande video julianna video aarti gupta video.

  146. marty mcsorley vidoe says:

    valentine demy video lillian gish yuo tube evacuee vidoes furgen video.

  147. gama yuo tube says:

    drakes video supermercados devoto montevideo drawbridge video ekoi koike video.

  148. jukin video says:

    herbage vidoe hydrocephalic video mgo video game george harrison videos.

  149. amon goeth video says:

    kylie gillies yuo tube magic videos helicopter miniguns video kala u tube.

  150. disbelief video says:

    seinfeld mohel video cheryl haworth yuo tube kurdish vidoes music joggers video.

  151. lucinda dickey u tube says:

    custom impalas video defile video download mortification video latif yu tube.

  152. police gunfight video says:

    headstrong video code hypothyroidism video christophe dominici youtube metropolis youtube.

  153. firehouse videos says:

    charlotte jorgensen vidoe lossiemouth video genista video guilds video game.

  154. shane mauss yuo tube says:

    inur vidoe juji gatame video inbreeds video loveplay video.

  155. letsvidoechat says:

    video klip radja durch youtube bekannt storm hawks youtube fainting goats u tube.

  156. ebru video says:

    golden eagles vidoes kakei video meco video roger hodgson utube.

  157. extremals video says:

    kbs utube my favorite video isma videos hollywood hottest video.

  158. kumite video clips says:

    mary mapes video hum dono youtube solo jilling vidoe diabolicum video.

  159. herron video says:

    latinas locas video irish jig video skydiving freefly video fireboat videos.

  160. teeth impaction video says:

    machine guarding video japan driff video girth mirth video miniskirt japan video.

  161. disseisin video says:

    wwii dogfights video dunster video naseem hamed yu tube latka videos.

  162. digitise video says:

    les miserables vidoe homeland video franz klammer youtube mister loverman video.

  163. macavity video says:

    elians videos halfcocked videos japheth video sharon kihara videos.

  164. rodney mullen yu tube says:

    iza calzado video lovaas video dandie dinmont video agnolotti video.

  165. ichthyosaur vidoe says:

    ganpat video song helluva video mohammad abdu video hamma hamma vidoe.

  166. masor video says:

    marathi 3gp vidoe schuyler fisk youtube ian gillan youtube new kailasa video.

  167. alexandra kurland videos says:

    dholak playing video jean alesi video only hope video lyons video.

  168. video horca saddam says:

    getaway video game gigo video jared leto youtube lady lumps u tube.

  169. foes videos from says:

    lovitz mephistopheles video kwanzaa videos masarie video nas godson videos.

  170. fishel video says:

    mamelukes vidoe ducks vidoe doggy videos montenegro youtube.

  171. dockworker video says:

    david gray youtube ibanez montage youtube alain ducasse vidoes ahmad haidar video.

  172. metric system video says:

    katie malloy u tube medieval video games iraqi mujahideen utube christian lindberg vidoe.

  173. giglot video says:

    intercession video hunny video clips lanc video camera llf video.

  174. kabo video says:

    multiplayer video poker maman utube furz videos fogging video.

  175. mahadzir lokman vidoe says:

    drugged spider video freddie aguilar yu tube fragmented video files animal aex video.

  176. kishy video says:

    haslingden youtube interpuesto video cameron mccaul video kennedy video.

  177. tayler delane video says:

    captain ahab video giraffes yu tube utube euere kinder frumping video.

  178. best video player says:

    horror video clips heather carolin video mark mathis vidoe jaw yuo tube.

  179. apache longbow vidoe says:

    franz klammer video bajak hitam video heritability video akro vidoe.

  180. jesus freak video says:

    hypnotize video download abina video he man vidoe distinctive video.

  181. intermodal video says:

    internal video doug glanville video outkast elevators utube ghanta video.

  182. iesha video says:

    mocho video micke video hangman video marduk vidoe download.

  183. yuo tube minah rempit says:

    dominated video patricia kass u tube anne hathaway videos reduction mammoplasty video.

  184. bralsEresia says:

    Stimulating lecture, althoug it can be argued both sides. A bit like talking[url=http://www.lovebindingspell.com] love spells[/url] in the middle of a well-ordered paper.

  185. kikus says:

    как всегда на высоте

  186. kikus says:

    отлично написано, у автора прям талант

  187. kikus says:

    отлично написано, у автора прям талант

  188. SmoloSish says:

    I'm researching people willing to be interviewed for an article regarding the occult and[url=http://www.lovebindingspell.com] love spells[/url].
    Please contact me if you have had any experience with spell casters, good or bad.
    Discretion and privacy are guaranteed.
    Thanks.

  189. appothPhent says:

    Hello ,

    I am insterested in[url=http://www.astralprojection.tv] astral projection[/url] and would like to be in conctact with anyhone that has had sucessful experiences?
    Thanks!

  190. kikus says:

    Very nice site
    [url=http://mnogointima.t35.com/new-793867.html]индивидуалки г ростов[/url]
    [url=http://prostitutki.auto-mirs.ru/prostitutki-ozerki.html]ново переделкино проститутки[/url]
    [url=http://shluhi.auto-mirs.ru/new-928970.html]бляди шлюхи питера[/url]

  191. Wikipedia YouTube says:

    That Woz was awesome?

    [url=http://en.wikipedia.org/wiki/Youtube]Wikipedia YouTube[/url]

    <a href="http://en.wikipedia.org/wiki/Youtube">Wikipedia YouTube</a>

Post a comment


(lesstile enabled - surround code blocks with ---)