TAILIEUCHUNG - Code Leader Using People, Tools, and Processes to Build Successful Software phần 5

Thông báo cho bạn biết đó khẳng định thất bại, nhưng nó có phân tích cú pháp bởi một con người để xác định một trong hai khẳng định của bạn không thành công và gây ra các kiểm tra như một toàn bộ để thất bại. Tốt hơn để phá vỡ mã kiểm tra của bạn vào các phương pháp thử nghiệm riêng biệt, mỗi với một sự khẳng định: | Part II Process The problem with this test is that it makes two separate assertions. The test asserts two different results for the method to return. If either fails the test as a whole will fail. However that means that when examining the test results the actual failure message has to be examined to determine what path through your code caused the failure. If the result for Tuesday is incorrect the result might be as output by NUnit TestCase failed Expected string length 14 but was 13. Strings differ at index 6. Expected Hello Tuesday But was Hello Friday The message tells you which assertion failed but it takes parsing by a human to determine which one of your two assertions failed and caused the test as a whole to fail. Better to break up your test code into two separate test methods each with one assertion Test public void TestProperDateFormatMonday Coverage c new Coverage string monday Hello Monday monday Test public void TestProperDateFormatTuesday Coverage c new Coverage string tuesday Hello Tuesday tuesday This way the failure is immediately apparent from looking at the name of the method that failed TestCase failed Expected string length 14 but was 13. Strings differ at index 6. Expected Hello Tuesday But was Hello Friday z This also requires you to pay attention to how you name your test methods. If you are careful about naming your test methods so that they reflect exactly what you are trying to test the results will be easier to analyze when tests fail. There are some cases where you may want to combine multiple calls to your test framework s assertion methods into one logical assertion. For instance if the result that you are asserting the value of is a member of another object like this Test public void CorrectRealPortionOfComplexNumber .

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.