Pragmatic Test Driven Development

Download Pragmatic Test Driven Development

Post on 26-Jan-2015

1.598 views

Category:

Technology

1 download

Embed Size (px)

DESCRIPTION

Slides from Integrum's

TRANSCRIPT

<ul><li> 1. Pragmatic Test Driven DevelopmentSunday, January 22, 12</li></ul> <p> 2. Your Host Clayton Lengel-Zigich Certified Scrum Master Certified Scrum Product Owner Certified Scrum Professional clayton@integrumtech.com @claytonlzSunday, January 22, 12 3. Types of TestingSunday, January 22, 12 4. Types of TestingAcceptance Integration UnitSunday, January 22, 12 5. Types of Testing This piece should be 24 These third-party rubber feet should fit Given all of these pieces, I can sit in the chair PONGSunday, January 22, 12 6. Types of TestingAcceptance Unit Unit UnitSunday, January 22, 12 7. Types of Testing FeatureFeatureFeature AcceptanceAcceptance AcceptanceUnitUnit Unit UnitUnitUnit UnitUnitUnit FeatureFeatureFeature AcceptanceAcceptance AcceptanceUnitUnit Unit UnitUnitUnit UnitUnitUnitSunday, January 22, 12 8. Whos Responsible?Sunday, January 22, 12 9. Whos Responsible? QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QA QAQA QA QA QA QA QA QA QA QA QA QA QA QA QA QASunday, January 22, 12 10. Whos Responsible? QASunday, January 22, 12 11. Who Writes Unit Tests?Sunday, January 22, 12 12. Who Writes Acceptance Tests? CUSTOMER Discovery DEV QASunday, January 22, 12 13. Automated TestingSunday, January 22, 12 14. Continuous Integration Continuous integration avoids or detects compatibility problems early ... if you integrate throughout the project in small amounts you will not find your self trying to integrate the system for weeks at the projects end while the deadline slips by. Always work in the context of the latest version of the system.Sunday, January 22, 12 15. Continuous Integration SCMBuild Server SCMSunday, January 22, 12 16. Continuous IntegrationCompilationBuildExecutes Tests ServerDefines StatusSunday, January 22, 12 17. Continuous Integration 10 MINUTE BUILDSunday, January 22, 12 18. Test First ProgrammingSunday, January 22, 12 19. Test First ProgrammingSunday, January 22, 12 20. Test Driven DevelopmentSunday, January 22, 12 21. Test Driven Development Test CodeSunday, January 22, 12 22. Test Driven DevelopmentFailingPassing RefactoredSunday, January 22, 12 23. Test Driven Development Failing FailingPassing Acceptance Test Unit TestUnit Test RefactorSunday, January 22, 12 24. Test Driven Development CodeCode Code Code Test Code Code TimeTest Code Test Code Test Code Test TimeSunday, January 22, 12 25. Frameworks and ToolsSunday, January 22, 12 26. Frameworks And Tools xUnitSunday, January 22, 12 27. Frameworks And Tools xUnitLanguageJUnit JavaNUnit .Net TestUnit Ruby QUnitJavaScript PhpUnitPHPSunday, January 22, 12 28. Pair ProgrammingSunday, January 22, 12 29. Pair Programming Write Test Write CodeSunday, January 22, 12 30. Tutorial #1Sunday, January 22, 12 31. Test Unit Fundamentals test_strike_strike_ball_ball_ball vs test_full_countSunday, January 22, 12 32. Test Unit Fundamentals Setup Assertion Assertion Assertion Tear DownSunday, January 22, 12 33. Test Unit Fundamentals assert(test, msg = (nomsg = true; nil)) assert_equal(exp, act, msg = nil) assert_no_match(regexp, string, msg=nil) assert_not_equal(exp, act, msg=nil) assert_not_nil(exp, msg=nil) assert_not_same(expected, actual, message="") assert_nothing_raised(*args) assert_nothing_thrown(msg=nil) assert_raise(*args, &amp;b) assert_respond_to(obj, meth, msg = nil)Sunday, January 22, 12 34. TDD RUles1.Only write code that makes a test pass2.Only write enough of a test to make it fail3.Only write enough code to make a test passSunday, January 22, 12 35. Tutorial #1 In pairs, write a program that can play the game of hangman. 50mActivity TimeSunday, January 22, 12 36. Mocking &amp; STUBBING Mocks vs. Stubs Indirect Outputs vs. Indirect InputsObjects vs. Methods Behavior vs. StateSunday, January 22, 12 37. Mocking Warehouse ? Order ? ?Sunday, January 22, 12 38. Mocking order.items.each do |item| warehouse_item = Warehouse.find(item) warehouse_item.stock_reservation.reserve end WarehouseWarehouseItem Order StockReservationSunday, January 22, 12 39. MockingWarehouse.reserve(items) Warehouse OrderSunday, January 22, 12 40. Mockingfake_warehouse = mock(Warehouse)assert(fake_warehouse.received("reserve").with(items),"Expected the warehouse to check its stock")Sunday, January 22, 12 41. STUBBING If any items are out-of-stock,the system should prevent theorder from completing CUSTOMERSunday, January 22, 12 42. STUBBINGdef test_out_of_stockorder = Order.newitem1 = Item.new(:sku =&gt; "abc")item2 = Item.new(:sku =&gt; "def")order.items = [item1, item2]stock_item1 = StockItem.new(:sku =&gt; zyx)...endSunday, January 22, 12 43. STUBBINGdef test_invalid_itemsWarehouse.stub(:reserve) .and_raise(OutOfStockException)assert_raise(OutOfStockException) doorder.completeendendSunday, January 22, 12 44. Tutorial #2Sunday, January 22, 12 45. Tutorial #2 In pairs, write a program that implements Conways game of life.45m Activity TimeSunday, January 22, 12 46. Game of LifeThe universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of whichis in one of two possible states, alive or dead. Every cellinteracts with its eight neighbors, which are the cells thatare horizontally, vertically, or diagonally adjacent. At eachstep in time, the following transitions occur:Sunday, January 22, 12 47. Game of Life: Rules Any live cell with fewer than two live neighbors dies, 1 as if caused by under-population. Any live cell with two or three live neighbors lives on2to the next generation. Any live cell with more than three live neighbors dies,3as if by overcrowding. Any dead cell with exactly three live neighbors4becomes a live cell, as if by reproduction.Sunday, January 22, 12 48. ClosingSunday, January 22, 12 49. Test FeedbackListen to your testsSunday, January 22, 12 50. Code CoverageIf were not at 90% code coverage youre all workingon Saturday.MANAGEMENT assert(true)DEVSunday, January 22, 12 51. Continuously Integrate Live and Die by the buildSunday, January 22, 12 52. Plan to SucceedBDDWrite tests before you plan the implementation Failing Unit Test TDDPassingUnit Test RefactorSunday, January 22, 12 </p>