Your SlideShare is downloading. ×
  • Like
Testing outside of the Ruby World
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Testing outside of the Ruby World

  • 5,777 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,777
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
16
Comments
0
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. T O fRb W r Joseph Wilk
  • 2. W ’R b fr ?
  • 3. Sr ...N R b . R .
  • 4. “The number of languages you know corresponds to your programming skill” S
  • 5. Y ... TJUnit ScrewUnitRspec JBehavePHPSpec JasmineJSpec CucumberCircumspec BlahSpecSomethingSpec WhateverSpec
  • 6. Y ... TJUnit ScrewUnitRspec BORING! JBehavePHPSpec JasmineJSpec CucumberCircumspec BlahSpecSomethingSpec WhateverSpec
  • 7. T &MRubyMonkey.stub!(:new).and_return(mock("monkey"))JavaI owe you one Java mocking example.I don’t have the will power to write it.Sorry.
  • 8. T &MRuby BORING!Monkey.stub!(:new).and_return(mock("monkey"))JavaI owe you one Java mocking example.I don’t have the will power to write it.Sorry.
  • 9. I r Asynchronous Property testingPermutation Model testingexplosions Metrics Test feedback Graphical tests
  • 10. H Curry
  • 11. “Program testing can be used to show thepresence of bugs, but never to show theirabsence!” Edsger Dijkstra
  • 12. Q C PropertiesFor all values of s the length of the thingreturned by five_random_characters is 5
  • 13. Q C Properties QuickCheck RandomlyLogic generate Function tests
  • 14. Q C Properties QuickCheck RandomlyLogic generate Function tests
  • 15. Q C Properties QuickCheck RandomlyLogic generate Function tests
  • 16. Q C Properties QuickCheck RandomlyLogic generate Function tests
  • 17. Q C Properties QuickCheck RandomlyLogic generate Function tests Counter Examples
  • 18. Q C Propertiesit "should reverse a string" do "monkeys".reverse.reverse.should == "monkeys"end100.times.map {“#{rand(10)}#{rand(10)}”}.each do |char| it "should reverse a string" do char.reverse.reverse.should == char endend
  • 19. Q C Propertiesimport Data.Charimport Test.QuickCheckinstance Arbitrary Char where arbitrary = choose (32, 128) coarbitrary c = variant (ord c `rem` 4)prop_RevRev xs = reverse (reverse xs) == xs where types = xs::[Char]$ Main> quickCheck prop_RevRevOK, passed 100 tests.
  • 20. Er Messaging/ Concurrency
  • 21. M Er Models Erlang McErlang runtime runtime system systemcommunication concurrency distribution
  • 22. M Er Modelsmessage Messenger “Scottish“Scottish Service fiction”fiction” Message login login Message client client Fred Clara
  • 23. M Er Modelsif user1 does not send a message m to user2 until user2 is logged on,then if user1 does send a message m to user2then eventually user2 receives the message m. "not P until Q => (eventually P => eventually R)” P: clara sends message “Scottish fiction” to fred Q: fred is logged on R: fred receives the message “Scottish fiction” from clara
  • 24. M Er Models{program={scenario,start,[[[{logon,clara},{message,fred,"hi"},logoff],[{logon,fred},logoff]]]},monitor={mce_ltl_parse:ltl_string2module_and_load("not P until Q implies (eventually P implieseventually R)", messenger_mon),{void,[{P,basicPredicates:message_to(clara,fred,"hi")}, {Q,basicPredicates:logon(fred)}, {R,basicPredicates:message_received(fred,clara,"hi")}]}}, algorithm={mce_alg_buechi,void}}).
  • 25. “Every method you use to prevent or findbugs leaves a residue of subtler bugs againstwhich those methods are ineffectual Pesticide Paradox / Beizer
  • 26. C r Bracket hell
  • 27. M Facts(fact (alive-in-next-generation? ...cell...) => truthy   (provided    (alive? ...cell...) => false    (neighbor-count ...cell...) => 3))cell = mock("a cell")cell.stub(:alive?).and_return(false)cell.stub(:neighbour_count).and_return(3)cell.alive_in_next_generation.should == true
  • 28. I Brief visit
  • 29. ISpecs are documentation
  • 30. ISpecs are documentation
  • 31. J v S rp Without the Java
  • 32. Z b .Trapped inside a browser
  • 33. Z b . Trapped inside a browservar zombie = require("zombie");var assert = require("assert");zombie.visit("http://localhost:3000/", function (err, browser, status) { browser. fill("email", "zombie@underworld.dead"). pressButton("Sign Me Up!", function(err, browser, status) { assert.equal(browser.text("title"), "Welcome"); })});
  • 34. V w Topics{ topic: function () { return 42 }, should be a number: function (topic) { assert.isNumber (topic); }, should be equal to 42: function (topic) { assert.equal (topic, 42); }}
  • 35. V w Asynchronous calls{ topic: function () { fs.stat(~/FILE, this.callback); }, can be accessed: function (err, stat) { assert.isNull (err); // We have no error assert.isObject (stat); // We have a stat object }, is not empty: function (err, stat) { assert.isNotZero (stat.size); // The file size is > 0 }}
  • 36. V w Promises / Futures{ topic: function () { var promise = new(events.EventEmitter); fs.stat(~/FILE, function (e, res) { if (e) { promise.emit(error, e) } else { promise.emit(success, res) } }); return promise; }, can be accessed: function (err, stat) { assert.isNull (err); //We have no error assert.isObject (stat); //We have a stat object }, is not empty: function (err, stat) { assert.isNotZero (stat.size); //The file size is > 0 }}
  • 37. V w Parallel Execution{ /dev/stdout: { topic: function () { path.exists(/dev/stdout,this.callback) }, exists: function (result) { assert.isTrue(result) } }, /dev/tty: { topic: function () { path.exists(/dev/tty,this.callback) }, exists: function (result) { assert.isTrue(result) } }, /dev/null: { topic: function () { path.exists(/dev/null,this.callback) }, exists: function (result) { assert.isTrue(result) } }}
  • 38. T Sw rPermutation Explosion
  • 39. T Sw rPermutation Explosion
  • 40. J v Really
  • 41. J MFaster Test feedback Failures are not randomly distributed Lots of very short tests A few very long ones Kent Beck
  • 42. J MFaster Test feedback
  • 43. I r L Learn from Metrics
  • 44. O r ff dessert
  • 45. ‘‘What is the use of a book,’’ thought Alice,‘‘without pictures or conversations?’’ Lewis Carroll Alice’s Adventures in Wonderland
  • 46. Sw LWords are not enough Ward Cunningham
  • 47. http://vimeo.com/22165070 Ward Cunningham
  • 48. Gr p T Brian Marick
  • 49. ‘‘How much do you know about the heuristics of failure?’ Joseph Wilk Scotland Ruby Conf 2011http://testobsessed.com/wp-content/uploads/2007/02/testheuristicscheatsheetv1.pdf
  • 50. T I
  • 51. Joseph Wilk ! @josephwilkhttp://blog.josephwilk.net