Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
declare function testFeature() {  let $actual := feature:doFeature()  (: assert feature condition :)};declare function doF...
declare function doFeature() {  let $output := lotsOfLogic()  return $output};
import module namespace build = “b” at “/build.xqy”;declare function testBuildXml() {  let $actual := b:buildXml()  (: ass...
import module namespace build = “b” at “/build.xqy”;declare function buildXml_condition1() {  (: ... :)};declare function ...
declare function bizLogic($input as element()*) {  (: ... :)};import module namespace logic = “logic” at “/logic.xqy”;decl...
declare function bizLogic($input as element()*) {  (: ... :)};import module namespace logic = “logic” at “/logic.xqy”;decl...
declare function businessLogic($input) {  let $moreInput := /more-input[@attr eq $input]  let $returnVal :=    for $item i...
declare function businessLogic($input) {  let $moreInput := /more-input[@attr eq $input]  let $returnVal :=    for $item i...
xdmp:get-request-field(“var”)xdmp:redirect-response(“/page.xqy”)
fn:collection()/dances/rainxdmp:document-insert(“/trades.xml”, element beads {})
declare function feature() {  let $filter := xdmp:get-request-field(“filter”)  let $input := fn:collection()/data[@attr eq...
declare function feature() {  let $filter := xdmp:get-request-field(“filter”)  let $input := fn:collection()/data[@attr eq...
All Creative Commons 2.0 Attribution License unless otherwise notedGreen Ferrari Front (modified)                         ...
Indian Chiefhttp://www.flickr.com/photos/boston_public_library/4100786887/in/photostream/Boston Public Librarys photostrea...
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Test-driven Development on MarkLogic
Upcoming SlideShare
Loading in …5
×

Test-driven Development on MarkLogic

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!

  • Login to see the comments

  • Be the first to like this

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/rainxdmp: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 notedGreen Ferrari Front (modified) Neon Pipeshttp://www.flickr.com/photos/zouny/5054032055/ http://www.flickr.com/photos/krossbow/3619931451/Design By Zounys photostream krossbows photostream - CC Attribution licenseGreen Ferrari Side (modified) Calculatorhttp://www.flickr.com/photos/zouny/5054024045/ http://www.flickr.com/photos/scoobay/2463236523/Design By Zounys photostream Scoobays photostreamBelay Water Droplethttp://www.flickr.com/photos/picsbycam/5173647461/ http://www.flickr.com/photos/shannonkringen/4680455907/Cameron Cassans photostream shannonkringens photostreamThinker Decoupledhttp://www.flickr.com/photos/garysoup/2705102139/ http://www.flickr.com/photos/daquellamanera/2213902727/Gary Soups photostream Daquella maneras photostreamClean Up Pointing Caterpillarhttp://www.flickr.com/photos/emilyrides/5188289325/lightbox/ http://www.flickr.com/photos/pinkstockphotos/5266977224/emilydickinsonridesabmxs photostream PinkStock Photos!s photostreamElephant Multiplicationhttp://www.flickr.com/photos/greenboots76/2924276160/ http://www.flickr.com/photos/somegeekintn/4048155967/Henry Bretts photostream somegeekintns photostreamChihuahua Cliffhttp://www.flickr.com/photos/62337512@N00/3727104807/ http://www.flickr.com/photos/elsie/144702426/apdks photostream Elsie esq.s photostreamAngry Dog Pig Egghttp://www.flickr.com/photos/javiercito/2083111412/lightbox/ http://www.flickr.com/photos/katerha/5423107783/Javiercit0s photostream katerhas photostreamClean up Pet Spaghetti Noodlehttp://www.flickr.com/photos/pointshoot/1144799868/ http://www.flickr.com/photos/pinksherbet/2201247567/Eddie~S photostream Pink Sherbet Photographys photostreamHugging Fingers Girl Eating Spaghettihttp://www.flickr.com/photos/ganesha_isis/4439563089/ http://www.flickr.com/photos/pinksherbet/5008273559/ganesha.isis photostream Pink Sherbet Photographys photostreamFail Whale Camoflauge Lizardhttp://www.flickr.com/photos/coletivomambembe/3882172324/ http://www.flickr.com/photos/lofink/4453281926/Coletivo Mambembes photostream dlofinks photostreamRoad Runner Salute Flaghttp://www.flickr.com/photos/snowpeak/4815685925/ http://www.flickr.com/photos/soldiersmediacenter/3920702814/snowpeaks photostream The U.S. Armys photostreamKeyboard Sleep Call on Beachhttp://www.flickr.com/photos/ytruly/1718468702/ http://www.flickr.com/photos/zitona/2268296925/YTrulys photostream » Zitona «s photostreamWinding Roadhttp://www.flickr.com/photos/dominicspics/422146490/Dominics pics photostream
  14. 14. Indian Chiefhttp://www.flickr.com/photos/boston_public_library/4100786887/in/photostream/Boston Public Librarys photostreamNinja Turtlehttp://www.flickr.com/photos/86805724@N00/1581833575/ianmalcms photostreamPhone Boothhttp://www.flickr.com/photos/bexwalton/4204409348/Bex.Waltons photostreamPicassohttp://www.flickr.com/photos/oddsock/101164507/oddsocks photostreamSuithttp://www.flickr.com/photos/pss/4830803189/Paul Stevensons photostreamUnderwaterhttp://www.flickr.com/photos/andreweick/4000567498/in/photostream/AndrewEicks photostreamSpider Tunnelhttp://www.flickr.com/photos/b1gw1ght/900924265/b1gw1ghts photostreamSafety Nethttp://www.flickr.com/photos/iamchadhearmesnore/3629410556/iamchads photostreamBlack Boxhttp://www.flickr.com/photos/amagill/34762677/AMagills photostreamThe SwededBy David Quinn, used with permissionRed Ferrari Enginehttp://www.flickr.com/photos/49889874@N05/5027004240/marc falardeaus photostreamKodak Rollhttp://www.flickr.com/photos/picsbycam/4550970565/in/photostream/Cameron Cassans photostreamGnuolane Free fonthttp://typodermicfonts.comFree for personal and commercial use

×