T       O    fRb W r      Joseph Wilk
W     ’R b   fr   ?
Sr         ...N R b             .  R     .
“The number of languages you know corresponds to your programming               skill”           S
Y ... TJUnit             ScrewUnitRspec             JBehavePHPSpec           JasmineJSpec             CucumberCircumspec  ...
Y ... TJUnit             ScrewUnitRspec               BORING!                  JBehavePHPSpec           JasmineJSpec      ...
T              &MRubyMonkey.stub!(:new).and_return(mock("monkey"))JavaI owe you one Java mocking example.I don’t have the ...
T              &MRuby                                 BORING!Monkey.stub!(:new).and_return(mock("monkey"))JavaI owe you on...
I    r  Asynchronous            Property testingPermutation                      Model testingexplosions  Metrics         ...
H    Curry
“Program testing can be used to show thepresence of bugs, but never to show theirabsence!”                             Eds...
Q               C               PropertiesFor all values of s the length of the thingreturned by five_random_characters is 5
Q         C            Properties            QuickCheck            RandomlyLogic        generate    Function              ...
Q         C            Properties            QuickCheck            RandomlyLogic        generate    Function              ...
Q         C            Properties            QuickCheck            RandomlyLogic        generate    Function              ...
Q         C            Properties            QuickCheck            RandomlyLogic        generate    Function              ...
Q         C            Properties            QuickCheck            RandomlyLogic        generate    Function              ...
Q              C                     Propertiesit "should reverse a string" do  "monkeys".reverse.reverse.should == "monke...
Q             C                    Propertiesimport Data.Charimport Test.QuickCheckinstance Arbitrary Char where  arbitrar...
Er      Messaging/     Concurrency
M Er   Models    Erlang               McErlang   runtime               runtime    system                systemcommunicatio...
M Er Modelsmessage       Messenger                               “Scottish“Scottish      Service                          ...
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 ...
M Er    Models{program={scenario,start,[[[{logon,clara},{message,fred,"hi"},logoff],[{logon,fred},logoff]]]},monitor={mce_...
“Every method you use to prevent or findbugs leaves a residue of subtler bugs againstwhich those methods are ineffectual  ...
C   r    Bracket      hell
M                      Facts(fact (alive-in-next-generation? ...cell...) => truthy   (provided    (alive? ...cell...) => f...
I    Brief visit
ISpecs are documentation
ISpecs are documentation
J v S rp     Without     the Java
Z        b .Trapped inside a browser
Z           b .               Trapped inside a browservar zombie = require("zombie");var assert = require("assert");zombie...
V w                    Topics{ topic: function () { return 42 },    should be a number: function (topic) {       assert.is...
V w                 Asynchronous calls{ topic: function () {     fs.stat(~/FILE, this.callback);  },  can be accessed: fun...
V w                 Promises / Futures{ topic: function () {     var promise = new(events.EventEmitter);     fs.stat(~/FIL...
V w                          Parallel Execution{ /dev/stdout: {     topic:    function   () { path.exists(/dev/stdout,this...
T Sw rPermutation Explosion
T Sw rPermutation Explosion
J v      Really
J       MFaster Test feedback            Failures are not            randomly distributed            Lots of very short te...
J       MFaster Test feedback
I         r     L    Learn from Metrics
O   r             ff        dessert
‘‘What is the use of a book,’’ thought Alice,‘‘without pictures or conversations?’’                                       ...
Sw       LWords are not enough                   Ward Cunningham
http://vimeo.com/22165070                   Ward Cunningham
Gr p   T           Brian Marick
‘‘How much do you know about the           heuristics of failure?’                                                    Jose...
T   I
Joseph Wilk                             !      @josephwilkhttp://blog.josephwilk.net
Upcoming SlideShare
Loading in …5
×

Testing outside of the Ruby World

6,212 views
6,189 views

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,212
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
17
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Testing outside of the Ruby World

  1. 1. T O fRb W r Joseph Wilk
  2. 2. W ’R b fr ?
  3. 3. Sr ...N R b . R .
  4. 4. “The number of languages you know corresponds to your programming skill” S
  5. 5. Y ... TJUnit ScrewUnitRspec JBehavePHPSpec JasmineJSpec CucumberCircumspec BlahSpecSomethingSpec WhateverSpec
  6. 6. Y ... TJUnit ScrewUnitRspec BORING! JBehavePHPSpec JasmineJSpec CucumberCircumspec BlahSpecSomethingSpec WhateverSpec
  7. 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. 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. 9. I r Asynchronous Property testingPermutation Model testingexplosions Metrics Test feedback Graphical tests
  10. 10. H Curry
  11. 11. “Program testing can be used to show thepresence of bugs, but never to show theirabsence!” Edsger Dijkstra
  12. 12. Q C PropertiesFor all values of s the length of the thingreturned by five_random_characters is 5
  13. 13. Q C Properties QuickCheck RandomlyLogic generate Function tests
  14. 14. Q C Properties QuickCheck RandomlyLogic generate Function tests
  15. 15. Q C Properties QuickCheck RandomlyLogic generate Function tests
  16. 16. Q C Properties QuickCheck RandomlyLogic generate Function tests
  17. 17. Q C Properties QuickCheck RandomlyLogic generate Function tests Counter Examples
  18. 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. 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. 20. Er Messaging/ Concurrency
  21. 21. M Er Models Erlang McErlang runtime runtime system systemcommunication concurrency distribution
  22. 22. M Er Modelsmessage Messenger “Scottish“Scottish Service fiction”fiction” Message login login Message client client Fred Clara
  23. 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. 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. 25. “Every method you use to prevent or findbugs leaves a residue of subtler bugs againstwhich those methods are ineffectual Pesticide Paradox / Beizer
  26. 26. C r Bracket hell
  27. 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. 28. I Brief visit
  29. 29. ISpecs are documentation
  30. 30. ISpecs are documentation
  31. 31. J v S rp Without the Java
  32. 32. Z b .Trapped inside a browser
  33. 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. 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. 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. 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. 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. 38. T Sw rPermutation Explosion
  39. 39. T Sw rPermutation Explosion
  40. 40. J v Really
  41. 41. J MFaster Test feedback Failures are not randomly distributed Lots of very short tests A few very long ones Kent Beck
  42. 42. J MFaster Test feedback
  43. 43. I r L Learn from Metrics
  44. 44. O r ff dessert
  45. 45. ‘‘What is the use of a book,’’ thought Alice,‘‘without pictures or conversations?’’ Lewis Carroll Alice’s Adventures in Wonderland
  46. 46. Sw LWords are not enough Ward Cunningham
  47. 47. http://vimeo.com/22165070 Ward Cunningham
  48. 48. Gr p T Brian Marick
  49. 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. 50. T I
  51. 51. Joseph Wilk ! @josephwilkhttp://blog.josephwilk.net

×