Better Unit Testing with Approval Tests
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Better Unit Testing with Approval Tests

  • 3,761 views
Uploaded on

Deck from my task for SDC2013

Deck from my task for SDC2013

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

Views

Total Views
3,761
On Slideshare
1,400
From Embeds
2,361
Number of Embeds
4

Actions

Shares
Downloads
17
Comments
0
Likes
0

Embeds 2,361

http://lynnlangit.com 2,340
https://twitter.com 18
http://reader.aol.com 2
http://www.newsblur.com 1

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
  • www.ApprovalTests.com-->http://approvaltests.sourceforge.net/gitHub https://github.com/approvals/ApprovalTests.NetRuby  https://github.com/approvals/approval_tests
  • Teaching Kids Programming – at www.TeachingKidsProgramming.orgSmallBasicFun – extensions at http://extendsmallbasic.codeplex.com/Learn to Program -- http://learntoprogram.codeplex.com/
  • http://nuget.org/packages/ApprovalTests
  • 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)
  • 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
  • http://blog.approvaltests.com/2011/12/using-reporters-in-approval-tests.htmlPoint 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, BeyondCompare and CodeCompare (http://www.devart.com/codecompare/)Types – text, image, HTML, more?
  • 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)
  • 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#ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations (<func>, enum(r1Start,r1Length), enum(r2Start,r2Length)
  • 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
  • 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
  • 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.
  • 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
  • We will play the video here – here’s the URL -- http://www.youtube.com/playlist?list=PLFBA98F47156EFAA9
  • Future – Approval Katas or Koans“Try our bowling with approvals. - Java / C# with MS Test / C# with Nunit”
  • Be sure to read the FAQ - http://approvaltests.sourceforge.net/?q=node/3Llewellyn Falco and Dan Gilkerson
  • www.ApprovalTests.com-->http://approvaltests.sourceforge.net/
  • Lynn

Transcript

  • 1. SDC 2013
  • 2. Demo – Start Up
  • 3. Demo – Arrays
  • 4. Demo – Test a GUI
  • 5. Code QualitySource - http://thesmithfam.org/blog/2012/03/05/the-code-quality-continuum/
  • 6. Approval Tests in Java…
  • 7. MapReduce
  • 8. Demo –Testing MapReduce
  • 9. Llewellyn DanWho wrote ApprovalTests?
  • 10. • recipes)www.TeachingKidsProgramming.org • Free Courseware • Teach a Kid (Ages 10 ++) • Java or Microsoft SmallBasic