nguyên thủy và các đối tượng. Các phiên bản của phương pháp này mà nổi kiểm tra và tăng gấp đôi bao gồm một tham số bổ sung cho một yếu tố lỗi. So sánh hai floatingpoint số về bình đẳng gần như không bao giờ mang lại kết quả tương tự. Tham số cuối cùng là đồng bằng, cho thấy khả năng chịu đựng tối đa cho sự bất bình đẳng. | 528 CHAPTER 17 Unit testing assertEquals method is heavily overloaded with versions that take all Java primitives and objects. The versions of the method that check floats and doubles include an additional parameter for an error factor. Comparing two floatingpoint numbers for equality almost never yields the same result. The last parameter is the delta indicating the maximum tolerance for inequality. Running tests JUnit features a couple of ways to run the tests. The framework includes textbased and Swing-based test runners. The test runners point to an individual test case or a package containing test cases and runs everything that begins with test. When pointed at a package it loads every class starting with Test that implements Testcase and tries to run the methods starting with test. In this way JUnit allows you to create new tests that are automatically picked up and run. The results of running the AllTests suite which includes TestShoppingCart in the Swingbased test runner are shown in figure . The test runner displays the test class name at the top along with a Run button. When invoked the test runner performs the tests. The bar in the center turns either green or red with obvious connotations. If a single test fails to run the bar turns red and the test was a failure. The results window under the progress bar shows the tests that were run along with the results. The successful tests show up with green checkmarks and the failures show up in red. The Failures tab shows a stack trace for the failed test runs. Figure The Swing-based test runner automatically runs the test cases found in a particular package. Unit testing and JUnit 529 Figure shows the results when one of the tests in the suite fails to run. In this case the testGetCartTotal test failed dooming the entire test run to failure. Figure The results progress bar glows red when even a single test fails to run. Test suites Figures and show a collection of .