按照传统测试用例编写方式需要编写四条类似的测试用例,而且这四条的测试步骤几乎一样。如下表 1-表 4 所示:
表 1.密码输入域长度测试用例-不输入Test stepsExpected result1. Open a application….Can open normally2. No input in password field
3.SubmitAlert “password is not allowed blank”
表 2.密码输入域长度测试用例-小于 6 位Test stepsExpected result1. Open a application….Can open normally2. Input password with less than 6 digit in password filed
3.SubmitAlert “password length must be more than or equal 6 digit”
表 3.密码输入域长度测试用例-等于 6 位Test stepsExpected result1. Open a application….Can open normally2. Input password with 6 digit in password filed
3.SubmitSuccess
表 4.密码输入域长度测试用例-大于 6 位Test stepsExpected result1. Open a application….Can open normally2. Input password with more than 6 digit in password filed
3.SubmitSuccess
分析这四个测试用例,发现除了第二步输入的参数不同之外,其余步骤都一样。我们可以把这一参数抽离出来,通过矩阵模式可以将测试用例简化表示,如下表 5 所示:
表 5.密码输入域长度测试用例Test pointExpected resultExecute result不输入Alert “password is not allowed blank”
小于 6 位Alert “password length must be more than or equal 6 digit”
等于 6 位Success
大于 6 位Success