TAILIEUCHUNG - Phát triển Javascript - part 50

Tham khảo tài liệu 'phát triển javascript - part 50', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Improving Readability 463 Keep names as short as possible without sacrificing clarity. Group-related tests in separate test cases and indicate the relation in the test case name thus avoiding the same prefix in a large number of tests. Never state what code is expected to do using the word and doing so indicates the test is not specific enough . it is likely trying to test more than one aspect of the target method. Focus on the what and why not the how. Breaking Free of Technical Limitations All of the tests in Part III Real-World Test-Driven Development in JavaScript were written using libraries that consider any method whose name starts with test to be a test. This leaves room for adding other properties on the test case that are not run as tests. In the interest of using libraries without modification we have rolled with this ending up with a bunch of tests with names starting with test should which is a bit of a smell. Because we can easily add helper functions in a closure surrounding the test case there really is no need for the test case to reserve space for helper methods . function properties whose names do not start with the obligatory test . By considering any function-valued property a test test cases could allow more flexibility in the naming of tests. Luckily wrapping . JsTestDriver s TestCase function to do just that is simple. Listing shows an enhanced test case function. It works just like the original only all functions except setup and tearDown are considered tests. Listing Enhancing JsTestDriver s test case function function testCaseEnhanced name tests var testMethods var property for var testName in tests property tests testName if typeof property function A setUp tearDown .test testName testName test testName testMethods testName property return TestCase name testMethods Download from 464 Writing Good Unit Tests The function simply loops all the properties of the test object prepends function .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.