Lịch thi đấu Teardown Patterns Simpo PDF Merge và Split Version Chưa đăng ký bởi tất cả các lớp học TestCase, và sẽ sử dụng một cơ chế hủy diệt đối tượng chung chung như vậy nó sẽ không cần phải chăm sóc những loại của các đối tượng đã xóa . | Simpo PDF Merge and Split Unregistered Version - http public void testStatus_initial in-line setup Airport departureAirport new Airport Calgary YYC Airport destinationAirport new Airport Toronto YYZ Flight flight new Flight flightNumber departureAirport destinationAirport exercise SUT and verify outcome assertEquals teardown garbage-collected public void testStatus_cancelled in-line setup Airport departureAirport new Airport Calgary YYC Airport destinationAirport new Airport Toronto YYZ Flight flight new Flight flightNumber departureAirport destinationAirport still part of setup Exercise SUT and verify outcome assertEquals teardown garbage-collected These tests contain a fair amount of Test Code Duplication. Delegated Setup Refactoring Notes We can refactor the fixture setup logic by using an Extract Method refactoring to remove any frequently repeated code sequences into utility methods with Intent-Revealing Names. We leave the calls to the methods in the test however so that the reader can see what is being done. The method calls that remain within the test will convey the big picture to the test reader. The utility method bodies contain the irrelevant mechanics of carrying out the intent. If we need to share the Delegated Setups with another Testcase Class we can use either a Pull Up Method Fowler refactoring to move them to a Testcase Superclass or a Move Method Fowler refactoring to move them to a Test Helper class. Example Delegated Setup In this version of the test we use a method that hides the fact that we need two airports instead of creating the two airports needed by the flight within each Test Method. We could produce this version of the tests either through refactoring or by writing the test in this intent-revealing style right off the bat. Delegated Setup 414 SimpoRPDFRMergeandESplit ưnregistered Version - http public void .