Approval Tests at Agile 2012
Upcoming SlideShare
Loading in...5
×
 

Approval Tests at Agile 2012

on

  • 3,730 views

slides from our talk on Approval Tests at Agile 2012

slides from our talk on Approval Tests at Agile 2012

Statistics

Views

Total Views
3,730
Views on SlideShare
1,295
Embed Views
2,435

Actions

Likes
0
Downloads
7
Comments
0

4 Embeds 2,435

http://lynnlangit.wordpress.com 1902
http://lynnlangit.com 531
http://coderwall.com 1
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • www.ApprovalTests.com-->http://approvaltests.sourceforge.net/
  • Be sure to read the FAQ - http://approvaltests.sourceforge.net/?q=node/3Llewellyn Falco and Dan Gilkerson
  • Simple C# demo, show Console (breakpoint), Assert, Approve, Reporter with Add, then with Explain, then into Reporters (DiffHTMLDiff)Here are the steps from www.ApprovalTests.comStep 1: Create your scenario Step 2: Write that scenario in EnglishStep 3: Translate English to Code (TDD – name objects / methods FIRST)Step 4: Create Code so it works (Implement named objects / methods)Step 5: Run your test for feedback while you codeStep 6: Approve result so it continues to workStep 7: Change the requirement Step 8: See the new solution Step 9: Re-approve so it continues to work
  • ApprovalTests is a valuable PART of the testing tools that professional developers use
  • Image credit - http://www.elinext.com/test-driven-development
  • Teaching Kids Programming – at www.TeachingKidsProgramming.orgSmallBasicFun – extensions at http://extendsmallbasic.codeplex.com/Learn to Program -- http://learntoprogram.codeplex.com/
  • Simple C# demo, show Console (breakpoint), Assert, Approve, Reporter with Add, then with Explain, then into Reporters (DiffHTMLDiff)Here are the steps from www.ApprovalTests.comStep 1: Create your scenario Step 2: Write that scenario in EnglishStep 3: Translate English to Code (TDD – name objects / methods FIRST)Step 4: Create Code so it works (Implement named objects / methods)Step 5: Run your test for feedback while you codeStep 6: Approve result so it continues to workStep 7: Change the requirement Step 8: See the new solution Step 9: Re-approve so it continues to work
  • Demo the VS2010 plug in, right-click ‘Approve’ – only works when test has not passed already.Contents provided are serialized to the file, depending on the Writer (which is encapsulated and associated to the method, examples:Approve(“”)*.txtApproveHtml(“”)*.htmlApprove(WinForm)*.pngApprove(IExecutableQuery)*.txt (SQL statement source generally)The act of approving allows you to take the contents of the received file and write them Namer – creates file name based on method nameWriter (depending on type, i.e. string) – inserts contents of object (i.e. string) into the new fileApprover – checks to see whether *.received file equals *.approvedReporter – called only on failure and then report (show) both files (*.approved & *.received)Received file is the contents that you gave the Writer written to the that file, the type is determined by the Writer, i.e. tiff, png
  • Image from http://askville.amazon.com/loves-Ferrell-favorite-character-played/AnswerViewer.do?requestId=7446578
  • http://blog.approvaltests.com/2011/12/using-reporters-in-approval-tests.htmlReporters can be put at multiple levels, closest wins (assembly, class, method)Can use mult-reporter(s), separate with a commaPoint out that the reporters vary for the different (language) implementations, i.e. C#, Java, etc.. Point to the documentation!DiffReporter is a cascading reporter (supports multiple)Reporter are VIEWERS for results on test FAILURE onlyIncluded reporters which are not listed are also WinDiff, BeyondCompare and CodeCompare (http://www.devart.com/codecompare/)Types – text, image, HTML, more?List of free differencing tools - http://www.thefreecountry.com/programming/filecomparison.shtml
  • There is a header and lambda function for arrays that allows for thetesting circle.var word = "Llewellyn";Approvals.Approve(word, word.ToCharArray(), (c) => c+ " => " + (int)c);would produce:LlewellynL => 76l => 108e => 101w => 119e => 101l => 108l => 108y => 121n => 110
  • We will play the video here – here’s the URL -- http://www.youtube.com/playlist?list=PLFBA98F47156EFAA9
  • http://www.youtube.com/watch?v=52YouQkd-f8Can approve ‘parts’ of a form (controls), or reports (RDLC), different types of files, such as .tiff, etc…*to test part of a Form, must make that part (control) publicC# demo using WinDiff (or TortoiseImageDiff) – new code TDD, ReSharper or VS refactoring tools?Do a version of this demo - http://www.youtube.com/watch?v=k5Y_jo4Nn54Also for ArraysThere is a header and lambda function for arrays that allows for thetesting circle.var word = "Llewellyn";Approvals.Approve(word, word.ToCharArray(), (c) => c+ " => " + (int)c);would produce:LlewellynL => 76l => 108e => 101w => 119e => 101l => 108l => 108y => 121n => 110
  • About Unit Testing Legacy Code - http://c2.com/cgi/wiki?UnitTestingLegacyCodePhoto credit - http://www.typemock.com/blog/2011/06/21/who-wants-a-free-typemock-t-shirt-2/
  • Image credits - http://dilbert.com/strips/comic/2006-12-08/Biz opportunity (i.e. how much) Legacy code is out thereIntro the idea of using approvals for legacy code in addition to TDD (i.e. test-first on new code)Image credit - http://www.agilitrix.com/wp-content/uploads/2010/03/Legacy-Systems-ThoughtWorks-QTB.jpg
  • http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052
  • Explain the syntax of ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations (arg,arg,arg) in C# (9 overloads)Can pass  Enumerable, Array, RangeContrast to Debug.Assert (individual results) – ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations  much richer output, here you are testing EVERY element in combination
  • Download code for demo from: https://github.com/lynnlangit/ApprovalTests_CodeDemos_Agile2012Future – Approval Katas or Koans“Try our bowling with approvals. - Java / C# with MS Test / C# with Nunit”
  • www.ApprovalTests.com-->http://approvaltests.sourceforge.net/wzuill@yahoo.com

Approval Tests at Agile 2012 Approval Tests at Agile 2012 Presentation Transcript

  • An open source library for better Unit Testing Woody Zuill & Lynn Langit Agile 2012 – August 2012
  • Llewellyn Dan Who wrote ApprovalTests?
  • Unit Tests Unit Tests Integration Tests Function Tests Performance Tests Acceptance Tests Installation Tests Approval Tests and Test Types View slide
  • DEMOGETTING STARTED View slide
  • Building your Testing ToolkitTest RunnerTest CodeLibrariesManual testsAutomated tests & tools
  • TDD - Red, Green, Refactor
  • Approval Tests make it EASY…For Woody… For Lynn…• … for human evaluation of • … in multiple languages test results • … with visual results…• … to set up Tests• … to modify test output for readability Golden Master• … to maintain tests
  • DEMOEXPRESSIVENESS
  • Approving the Reported Result• Contents are serialized to a file as binary (to compare)• Rename *.received to *.approved• Right click ‘Use whole file’• Copy ‘Move’ statement from Test Results to command window.
  • More aboutreporters…
  • A Little About Reporters• Reporters provide a rich, expressive, human-friendly view of a failed test.• Reporters usually hook into DiffTools (Text, Image, Sound…)• Support for many diff tools included in Reporters• Can add hooks to your favorite diff tool
  • Best test output has…?
  • Best test output has...?Granularity• What is the result of a break• What is the specific cause of a breakFeedback• Frequent (or even constant) feedbackSpecification• What is this code supposed to do?• How do we use it?Regression-Proofing• Did what I just do break something?Automatic Design Process• TDD can be thought of as Test Driven Design
  • DEMOARRAYS
  • Approval Tests in Java…
  • DEMOGUIS
  • Code must be Testable
  • Code must be TestableCode must include TestsCode should be written so that it is easy to writeits required tests“Reduce to Functional”Code Tests must be kept runnable
  • Unit Test Frameworks are Multi-Purpose New Code • Application code (components) • FunctionalityTesting APIs • Edge cases • Locking testsLegacy Code • Characterization testsLearning new • Scope APIs • Functionality
  • Legacy CodeHow much of your code base is dead code?
  • Locking Tests (Characterization Tests) Ensures Quickly Test to Most often system still results in enable used with works the high testrefactoring Legacy Code same coverage
  • Legacy Code – Chart SmartDEMO
  • For More Information www.ApprovalTests.com Pick your language & download Pick your diff tool Reference, Approve & Enjoy Learn more – videos (.NET) Podcast - HerdingCode
  • @WoodyZuill @LynnLangit Q&A