Lập trình Wrox Professional Xcode 3 cho Mac OS part 72

Các nhà xây dựng tĩnh cho installTimer gây ra một thể hiện của đối tượng này được tạo ra trong quá trình khởi tạo các ứng dụng của bạn. Bởi vì hàm này là một phần của mã trong kiểm tra đơn vị, đối tượng UnitTestRunner chỉ tạo ra khi ứng dụng của bạn đang chạy trong sự hiện diện của các gói thử nghiệm đơn vị. | 572 CHAPTER 20 UNIT TESTING The static constructor for installTimer causes an instance of this object to be created during the initialization of your application. Because the constructor is part of the code in the unit test the UnitTestRunner object is only created when your application is running in the presence of the unit test bundle. The class creates a timer with a 0 interval and registers it with the Carbon event manager. As soon as the application has performed its basic initialization and the event loop is ready to run the timer fires. The testTimerFired function catches the timer event and invokes the runTests function. This function runs all of your unit tests and quits the application. In the absence of the unit test bundle there is no constructor no timer object is created and your application starts running normally. The beauty of this scheme is that it requires no modification to your application. There is no possibility of accidentally producing a version of your application that contains any unit test support and you can test the final application binary you intend to release. DEBUGGING UNIT TESTS Who watches the watchers Sometimes a unit test designed to keep your application free of bugs has bugs itself. When this occurs you need to bring the power of the debugging tools to bear on the unit test code rather than your application. The problem is that unit tests run during the build phase not the debug phase of the Xcode environment. The tests themselves are never the target of a Debug or Run command and you have the added catch-22 of trying to build an application whose unit tests fail. Debugging iPhone Application Tests However awkward an iPhone application dependent unit test is to set up and use it is stunningly simple to debug. Remember that an iPhone application test is a regular copy of your iPhone app that includes a unit testing bundle. To debug your application tests simply run your test application target under the control of the debugger

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
10    114    3    26-06-2024
13    90    1    26-06-2024
20    79    2    26-06-2024
Đã 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.