2015年4月5日星期日

Impression of Week 10

Week 10

Unit test and Assert statement

Unit test is used to test each small single cases of a function. Remind it can just represents one single case, so even the function passes some unit tests, it can still not be guaranteed that the function works well without bugs. However, if one choose a lot of unit tests which can conclude all cases that the function may face, passing all unit tests means the function is quite solid.


Assert statement is  an another way to check codes. In the process of writing code, a lot of different errors may occur while we do not know which part exactly is wrong. Thus, we may use print() method to print out the value of everything and check if they meet our expectation. However, the adding of print() is quite time consuming as we still need to remove them after we find out the solve the problem. A good alternative is assertions by implementing assert statements.

没有评论:

发表评论