1 / 63

A Second Look at Unit Testing

A Second Look at Unit Testing. @ RoyOsherove royo@bouvet.no. Unit Of Work Setup Methods Constrained vs. Unconstrained Isolation Frameworks Principles of Good Isolation Frameworks Faking Deep Legacy is OK Six Influence Forces Beautiful Builds. Test Review Lion. Bottleneck Ninja.

lynda
Download Presentation

A Second Look at Unit Testing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Second Look at Unit Testing @RoyOsherove royo@bouvet.no

  2. Unit Of Work • Setup Methods • Constrained vs. Unconstrained Isolation Frameworks • Principles of Good Isolation Frameworks • Faking Deep Legacy is OK • Six Influence Forces • BeautifulBuilds

  3. Test Review Lion Bottleneck Ninja Build Bear

  4. Test Public API Production Code Unit Of Work Unit Of Work Return Value/Exception Noticeable State Change 3rd Party call

  5. Test Assert Public API Production Code Unit Of Work Return Value/Exception

  6. Test Public API Assert Production Code Unit Of Work Noticeable State Change

  7. Test Assert Public API Production Code Unit Of Work 3rd Party Unit Of Work 3rd Party call

  8. Test Mock Assert Public API Production Code Unit Of Work 3rd Party Unit Of Work 3rd Party call

  9. UnitOfWork_Input_ExpectedOutput • UnitOfWork_LogicalAction_ExpectedChangeInBehavior • UnitOfWork_ActionOrInput_ExepectedCallToThirdParty Naming by Unit Of Work

  10. Addition_PositiveNumbers_ReturnsSum() • Addition_WhenCalled_ResetsTheNextSum() • Addition_NegativeNumbers_CallsLogger() Naming by Unit Of Work

  11. Setup Methods

  12. Constrained vs. • Unconstrained Isolation Frameworks

  13. Hello FakeItEasy, NSubstitute Goodbye RhinoMocks

  14. Usability • Readability • Good Errors • Simplicity • Robust future proof tests • Less over specification • Non strict • Recursive Fakes Isolation frameworks Futures

  15. Rspec style is ok Assert multiple results on same unit of work

  16. LEGACY CODEFaking Deep System Internals is OK Example - SilverUnit

  17. Cross Cutting Fakes

  18. Old code

  19. Cross Cutting fakes Old code Fake New code

  20. Impacting Change

  21. Personal Ability Motivation • Social Ability Motivation • Environmental Ability Motivation 6 influence forces

  22. Another book?

  23. Pex – yes • Moles (ms fakes) – NO • JustMock - Maybe • Nuget – YES • Chocolatey – YES • TeamCity – YES • FinalBuilder – YES • Ruby and Rake – Maybe • Amazon AWS agent hosting – YES • Git for very small commits - YES Tools

  24. Build and Delivery

  25. Build Patterns

  26. Allow version aware builds • Build scripts are part of source control • Build configurations on the CI server are dumb triggers Build Script Injection

  27. Extract Script Extract Script

  28. Build Chain Triggers Build Chaining Triggered by checkin Triggered by end of previous Manual Manual

  29. Slow Builds Do X Do X + Y Do X + Y + Z Do X + y + Z + N

  30. Cumulative, Fast Builds Do X Do Y Do Z Do N

  31. How Fast?

  32. Extract Script • Shipping Skeleton • Fill in the blanks • Cumulative Builds • Build Waves • Location Agnostic BeautifulBuilds.com

  33. (wtf how many books?)

  34. Beautiful builds • TDD with JS • TDD with Ruby • Art of Unit Testing in .NET from scratch • roy@osherove.com • Norway & Sweden • Osherove.com for info Courses I’m Doing

  35. A short song?

  36. This is a test line

  37. It looks like you’re doing just fine

  38. It’s time for a song of mine

  39. It’s late in the evening

  40. I’m wondering what words to say • It’s so hard to breath here • The customer’s face is gray It’s late in the evening

  41. And then he asks me Is the product alright?

More Related