Successfully reported this slideshow.

Test-driven Development on MarkLogic

1

Share

Loading in …3
×
1 of 53
1 of 53

Test-driven Development on MarkLogic

1

Share

Download to read offline

Unit testing is a required part of a healthy software development lifecycle and a balanced breakfast. Test-driven development is a rockin' part of an *awesome* development lifecycle. If you don't test-drive the dev of your MarkLogic XQuery, you may never come back to test again. Test-driven XQuery development will ease your headaches, put you into the plush seat of a developer with confidence, and rocket you down the road to making all your wildest dreams come true. Kachow!

Unit testing is a required part of a healthy software development lifecycle and a balanced breakfast. Test-driven development is a rockin' part of an *awesome* development lifecycle. If you don't test-drive the dev of your MarkLogic XQuery, you may never come back to test again. Test-driven XQuery development will ease your headaches, put you into the plush seat of a developer with confidence, and rocket you down the road to making all your wildest dreams come true. Kachow!

More Related Content

Test-driven Development on MarkLogic

  1. 1. declare function testFeature() { let $actual := feature:doFeature() (: assert feature condition :) }; declare function doFeature() { () (: todo: impl :) };
  2. 2. declare function doFeature() { let $output := lotsOfLogic() return $output };
  3. 3. import module namespace build = “b” at “/build.xqy”; declare function testBuildXml() { let $actual := b:buildXml() (: assert only xml is well-built :) }; import module namespace translate = “t” at “/transl8.xqy”; declare function testAddTranslateFlags() { let $actual := t:addTranslateFlags() (: assert only that translation flags added correctly :) };
  4. 4. import module namespace build = “b” at “/build.xqy”; declare function buildXml_condition1() { (: ... :) }; declare function buildXml_condition2() { (: ... :) }; (: etc. :)
  5. 5. declare function bizLogic($input as element()*) { (: ... :) }; import module namespace logic = “logic” at “/logic.xqy”; declare function bizLogic_emptyInput() { (: ... :) }; declare function bizLogic_oneInput() { (: ... :) }; declare function bizLogic_manyInput() { (: ... :) };
  6. 6. declare function bizLogic($input as element()*) { (: ... :) }; import module namespace logic = “logic” at “/logic.xqy”; declare function bizLogic_insufficientInput() { (: ... :) }; declare function bizLogic_malformedInput() { (: ... :) };
  7. 7. declare function businessLogic($input) { let $moreInput := /more-input[@attr eq $input] let $returnVal := for $item in $moreInput let $details := /detail[@id eq $item/id] return if ($details/thing eq xdmp:get-request-field(“thing-id”)) then $details else () return if (fn:exists($returnVal)) then let $audit := xdmp:document-insert(“/latest.xml”, element ok {}) return $returnVal else xdmp:redirect-response(“/empty.xqy”); };
  8. 8. declare function businessLogic($input) { let $moreInput := /more-input[@attr eq $input] let $returnVal := for $item in $moreInput let $details := /detail[@id eq $item/id] return if ($details/thing eq xdmp:get-request-field(“thing-id”)) then $details else () return if (fn:exists($returnVal)) then let $audit := xdmp:document-insert(“/latest.xml”, element ok {}) return $returnVal else xdmp:redirect-response(“/empty.xqy”); };
  9. 9. xdmp:get-request-field(“var”) xdmp:redirect-response(“/page.xqy”)
  10. 10. fn:collection()/dances/rain xdmp:document-insert(“/trades.xml”, element beads {})
  11. 11. declare function feature() { let $filter := xdmp:get-request-field(“filter”) let $input := fn:collection()/data[@attr eq $filter] let $result := businessLogic($input) let $persist := xdmp:document-insert(“/doc.xml”, $result) return xdmp:redirect-response(“complete.xqy”) };
  12. 12. declare function feature() { let $filter := xdmp:get-request-field(“filter”) let $input := fn:collection()/data[@attr eq $filter] let $result := businessLogic($input) let $persist := xdmp:document-insert(“/doc.xml”, $result) return xdmp:redirect-response(“complete.xqy”) };
  13. 13. All Creative Commons 2.0 Attribution License unless otherwise noted Green Ferrari Front (modified) Neon Pipes http://www.flickr.com/photos/zouny/5054032055/ http://www.flickr.com/photos/krossbow/3619931451/ Design By Zouny's photostream krossbow's photostream - CC Attribution license Green Ferrari Side (modified) Calculator http://www.flickr.com/photos/zouny/5054024045/ http://www.flickr.com/photos/scoobay/2463236523/ Design By Zouny's photostream Scoobay's photostream Belay Water Droplet http://www.flickr.com/photos/picsbycam/5173647461/ http://www.flickr.com/photos/shannonkringen/4680455907/ Cameron Cassan's photostream shannonkringen's photostream Thinker Decoupled http://www.flickr.com/photos/garysoup/2705102139/ http://www.flickr.com/photos/daquellamanera/2213902727/ Gary Soup's photostream Daquella manera's photostream Clean Up Pointing Caterpillar http://www.flickr.com/photos/emilyrides/5188289325/lightbox/ http://www.flickr.com/photos/pinkstockphotos/5266977224/ emilydickinsonridesabmx's photostream PinkStock Photos!'s photostream Elephant Multiplication http://www.flickr.com/photos/greenboots76/2924276160/ http://www.flickr.com/photos/somegeekintn/4048155967/ Henry Brett's photostream somegeekintn's photostream Chihuahua Cliff http://www.flickr.com/photos/62337512@N00/3727104807/ http://www.flickr.com/photos/elsie/144702426/ apdk's photostream Elsie esq.'s photostream Angry Dog Pig Egg http://www.flickr.com/photos/javiercito/2083111412/lightbox/ http://www.flickr.com/photos/katerha/5423107783/ Javiercit0's photostream katerha's photostream Clean up Pet Spaghetti Noodle http://www.flickr.com/photos/pointshoot/1144799868/ http://www.flickr.com/photos/pinksherbet/2201247567/ Eddie~S' photostream Pink Sherbet Photography's photostream Hugging Fingers Girl Eating Spaghetti http://www.flickr.com/photos/ganesha_isis/4439563089/ http://www.flickr.com/photos/pinksherbet/5008273559/ ganesha.isis' photostream Pink Sherbet Photography's photostream Fail Whale Camoflauge Lizard http://www.flickr.com/photos/coletivomambembe/3882172324/ http://www.flickr.com/photos/lofink/4453281926/ Coletivo Mambembe's photostream dlofink's photostream Road Runner Salute Flag http://www.flickr.com/photos/snowpeak/4815685925/ http://www.flickr.com/photos/soldiersmediacenter/3920702814/ snowpeak's photostream The U.S. Army's photostream Keyboard Sleep Call on Beach http://www.flickr.com/photos/ytruly/1718468702/ http://www.flickr.com/photos/zitona/2268296925/ YTruly's photostream » Zitona «'s photostream Winding Road http://www.flickr.com/photos/dominicspics/422146490/ Dominic's pics' photostream
  14. 14. Indian Chief http://www.flickr.com/photos/boston_public_library/4100786887/in/photo stream/ Boston Public Library's photostream Ninja Turtle http://www.flickr.com/photos/86805724@N00/1581833575/ ianmalcm's photostream Phone Booth http://www.flickr.com/photos/bexwalton/4204409348/ Bex.Walton's photostream Picasso http://www.flickr.com/photos/oddsock/101164507/ oddsock's photostream Suit http://www.flickr.com/photos/pss/4830803189/ Paul Stevenson's photostream Underwater http://www.flickr.com/photos/andreweick/4000567498/in/photostream/ AndrewEick's photostream Spider Tunnel http://www.flickr.com/photos/b1gw1ght/900924265/ b1gw1ght's photostream Safety Net http://www.flickr.com/photos/iamchadhearmesnore/3629410556/ iamchad's photostream Black Box http://www.flickr.com/photos/amagill/34762677/ AMagill's photostream The Sweded By David Quinn, used with permission Red Ferrari Engine http://www.flickr.com/photos/49889874@N05/5027004240/ marc falardeau's photostream Kodak Roll http://www.flickr.com/photos/picsbycam/4550970565/in/photostream/ Cameron Cassan's photostream Gnuolane Free font http://typodermicfonts.com Free for personal and commercial use

×