xunit test patterns refactoring test code phần 8

giúp ngăn ngừa các thử nghiệm Obscure bằng cách định nghĩa một ngôn ngữ cấp cao hơn (xem trang 41) để xác định các xét nghiệm. Nó cũng rất hữu ích để giữ cho các phương pháp tiện ích thử nghiệm tương đối nhỏ và khép kín. | Simpo PDF Merge and Split Unregistered Version - nttp help prevent Obscure Tests by defining a Higher Level Language see page 41 for defining tests. It is also helpful to keep the Test Utility Methods relatively small and self-contained. We can achieve this goal by passing all arguments to these methods explicitly as parameters rather than using instance variables and by returning any objects that the tests will require as explicit return values or updated parameters. To ensure that the Test Utility Methods have Intent-Revealing Names we should let the tests pull the Test Utility Methods into existence rather than just inventing Test Utility Methods that we think may be needed later. This outside-in approach to writing code avoids borrowing tomorrow s trouble and helps us find the minimal solution. Writing the reusable Test Utility Method is relatively straightforward. The trickier question is where we would put this method. If the Test Utility Method is needed only in Test Methods in a single Testcase Class page 373 then we can put it onto that class. If we need the Test Utility Method in several classes however the solution becomes a bit more complicated. The key issue relates to type visibility. The client classes need to be able to see the Test Utility Method and the Test Utility Method needs to be able to see all the types and classes on which it depends. When it doesn t depend on many types classes or when everything it depends on is visible from a single place we can put the Test Utility Method into a common Testcase Superclass page 638 that we define for our project or company. If it depends on types classes that cannot be seen from a single place that all the clients can see then we may need to put the Test Utility Method on a Test Helper in the appropriate test package or subsystem. In larger systems with many groups of domain objects it is common practice to have one Test Helper for each group package of related domain objects. Test .

Không thể tạo bản xem trước, hãy bấm tải xuống
142    73    5    29-11-2023
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.