Approval Tests - A Library for All Developers
Upcoming SlideShare
Loading in...5
×
 

Approval Tests - A Library for All Developers

on

  • 3,086 views

deck from my talk at SoCalCodeCamp June 2011 - library at www.ApprovalTests.com

deck from my talk at SoCalCodeCamp June 2011 - library at www.ApprovalTests.com

Statistics

Views

Total Views
3,086
Views on SlideShare
2,289
Embed Views
797

Actions

Likes
1
Downloads
14
Comments
0

8 Embeds 797

http://lynnlangit.wordpress.com 624
http://blogs.msdn.com 131
http://lynnlangit.com 35
http://weblog.chrisricard.net 3
http://www.slideshare.net 1
http://www.5z5.com 1
http://digg.com 1
http://www.newsblur.com 1
More...

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/
  • ice-breaker - Comic credit - http://almaer.com/blog/uploads/feelingagile.png
  • Idea here is common misconceptions, i.e. ‘why I do not do TDD’Why TDD == spec, feedback, granularity, regressionIke to tell story of ‘why’ TDD change lock.
  • change perception.Photo credit – “Seeing the Invisible” - http://fc03.deviantart.net/fs71/i/2010/299/4/7/seeing_the_invisible_by_beloved_art-d31kfsc.jpg
  • 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
  • Make the point that you can use ApprovalTests at all levels of testing granularity – both TDD (small) and BDD (big) AND in between – Approvals == better Asserts
  • Lynn talks about set up in C#Direct to www.ApprovalTests.comLibrary (mandatory)DiffTool (can select type, but will want to use) VS2010 – TortoiseDiff, WinDiff, doesn’t not work with BeyondCompare yetPlug-in (optional)  right click (highlight test method)  Approve (only appears when test is failing)
  • Re-iterate the testing cycle steps for TDD for new code, maybe mention BDD hereShow that the first illustration is incomplete – doesn’t include the ‘think it out / visualize it’ step
  • Point out that the reporters vary for the different (language) implementations, i.e. C#, Java, etc.. Point to the documentation!Reporter are VIEWERS for results on test FAILURE onlyIncluded reporters which are not listed are also WinDiff and BeyondCompareTypes – text, image, HTML, more?
  • 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
  • Can 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 writing the ‘functional method(s)’ which will be tested by CombinationApprovalsTalk about the limits of ‘functional’ coding, not only for F#, i.e. coding in a functional way, testing in a functional way.  stored proc on visual.Photo credit – “Seeing the Invisible” - http://fc03.deviantart.net/fs71/i/2010/299/4/7/seeing_the_invisible_by_beloved_art-d31kfsc.jpg
  • 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
  • Testing non-deterministic results – blog – testing the weatherOn test “pass”, there is NOT call to the data source (web service, database, etc…)ILoader implements Load(), uses IExQuerycombines, creates abstract base LoaderForSystem, example:SQL  conn string, T-SQLEF  conn string, LINQWCF  server, URL (query)
  • 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
  • Explain the syntax of Approvals.ApproveAllCombinations(arg,arg,arg) in C# (9 overloads)Can pass  Enumerable, Array, RangeContrast to Debug.Assert (individual results) – Approvals.ApproveAllCombinations much richer output, here you are testing EVERY element in combination
  • Intro the idea of using approvals for legacy code in addition to TDD (i.e. test-first on new code)Code coverage in VS2010 Ultimate or can use DotCover (around $ 100), or othersCode Coverage is defined as running your tests and seeing how much of your code is ‘covered’
  • Intro the idea of using approvals for legacy code in addition to TDD (i.e. test-first on new code)
  • Legacy Code demo in Java, locking test, and code coverageDo a version of this demo - http://www.youtube.com/watch?v=EJ1tRFEOkcwDo this in C#CombinationApprovals.Approve (, enum(r1Start,r1Length), enum(r2Start,r2Length)
  • Besure to read the FAQ - http://approvaltests.sourceforge.net/?q=node/3
  • Future – Approval Katas or Koans“Try our bowling with approvals. - Java / C# with MS Test / C# with Nunit”
  • www.ApprovalTests.com-->http://approvaltests.sourceforge.net/

Approval Tests - A Library for All Developers Approval Tests - A Library for All Developers Presentation Transcript

  • Approval Tests
    Lynn Langit
    A library for you
  • So, are YOU Agile?
    Do you code in C#, VB.NET, Java, PHP or Ruby?
  • Why TDD?
    Better spec / scope
    Define, then create (objects)
    Do  Verify
    Feedback/regression/granularity
    But…
    Littered with Asserts?
    Extra work  less productivity?
    Why Test-Driven?
  • For Code Quality
    Tests are ‘kind of’ important
    Africa is ‘kind of’ big…
  • Demo
    How do I get started?
  • How Test-Driven
    TDD
    BDD
    Think Bigger
    Less Code
    Scenarios
    How do Approvals fit with both?
    Assert
    Do
    Verify
  • Setup
    Download Approvals
    Download IDE plugin
    VS2010, VS2008
    Select DiffTool(s)
  • Approve is the new Assert
    Applying Approvals
  • About Reporters
  • How to Approve
    • Rename *.received to *.approved
    • Right click ‘Approve’ (plug-in)
    • Right click ‘Use whole file’ (DiffReporter)
    • Copy ‘Move’ statement from Test Results to command window
    Contents provided are serialized to the file
  • Demo
    I want to test a GUI…
  • Functional ‘ality’
    Testing the untestable
    How do I make THAT functional?
  • Testing Arrays…
    Testing multiple values
  • Testing the Weather using SQL Server – Approvals.Approve(Loader…)
    DEMO
    Testing non-deterministic objects
  • Legacy Code
    How much of your code base is dead code?
  • Combinations
    Combination Approvals
  • Code Coverage
    How much of your code base is covered?
  • Coverage Config
    Code Coverage in VS 2010 Ultimate
  • Demo
    I want to test combinations...
  • Who wrote this?
    Dan Gilkerson (@dangilkerson)and Llewellyn Falco (@isidore_us)
  • Now I want THAT
    www.ApprovalTests.com
    Pick your language & download
    Pick your diff tool
    Reference, Approve & Enjoy
  • Approval Tests
    Lynn Langit@llangit
    Q & A