13 Testing
自己惯用测试用例:
Boundary: size = 0, 1, 2 & very big
robustness :null input, or [null]
functional : positive test case & negative test case
也得注意特殊输入,例如:一个数组[0, 0, 0]
除以0
加和时注意越界,例如:[1,2147483647]
如果要数字符数目的时候,要注意刚好相等的情况,例如:["a"], 1, 68 Text Justification
虽然输入只包含貌似合法的字符,数字跟点(.),但要注意00,01这些非法输入。例如:165 Compare Version
下面的从stackoverflow上抄下来的:
Based on the content of the algorithm you can identify what data structures/types/constructs are used. Then, you try to understand the (possible) weak points of those and try to come up with an execution plan that will make it run in those cases.
For example, the algorithm takes a string and an integer as input and does some sorting of the characters of the string.
Here we have:
String with some known special cases:
Integer with known special cases:
Sort algorithm that could fail in the following boundary cases:
Then, take all these cases and create a long list trying to understand how they overlap. Ex:
etc.
Now create test cases for them :)
Short summary: break the algorithm in basic blocks for which you know the boundary cases and then reassemble them, creating global boundary cases
Last updated