提交 9405689a 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

check actual result with #expect by @step group defined in scripts

上级 e1a1f328
......@@ -33,8 +33,6 @@ func ValidateTestCase(scriptFile string, langType string,
indx := 0
for _, step := range stepArr {
stepResult := true
var expectLines []string
if len(expectArr) > indx {
expectLines = expectArr[indx]
......@@ -45,26 +43,7 @@ func ValidateTestCase(scriptFile string, langType string,
actualLines = actualArr[indx]
}
checkpointLogs := make([]model.CheckPointLog, 0)
indx2 := 0
for _, expect := range expectLines {
log := "N/A"
if len(actualLines) > indx2 {
log = actualLines[indx2]
}
pass := MatchString(expect, log, langType)
if !pass {
stepResult = false
}
cp := model.CheckPointLog{Numb: indx2 + 1, Status: pass, Expect: expect, Actual: log}
checkpointLogs = append(checkpointLogs, cp)
indx2++
}
stepResult, checkpointLogs := ValidateStep(langType, expectLines, actualLines)
step := model.StepLog{Numb: indx + 1, Name: step, Status: stepResult, CheckPoints: checkpointLogs}
stepLogs = append(stepLogs, step)
......@@ -82,6 +61,34 @@ func ValidateTestCase(scriptFile string, langType string,
report.Cases = append(report.Cases, cs)
}
func ValidateStep(langType string, expectLines []string, actualLines []string) (bool, []model.CheckPointLog) {
stepResult := true
checkpointLogs := make([]model.CheckPointLog, 0)
indx2 := 0
for _, expect := range expectLines {
log := "N/A"
if len(actualLines) > indx2 {
log = actualLines[indx2]
}
pass := MatchString(expect, log, langType)
if !pass {
stepResult = false
}
cp := model.CheckPointLog{Numb: indx2 + 1, Status: pass, Expect: expect, Actual: log}
checkpointLogs = append(checkpointLogs, cp)
indx2++
}
return stepResult, checkpointLogs
}
func Print(report model.TestReport, workDir string) {
startSec := time.Unix(report.StartTime, 0)
endSec := time.Unix(report.EndTime, 0)
......@@ -125,7 +132,7 @@ func Print(report model.TestReport, workDir string) {
count++
}
} else {
PrintAndLog(&logs, " No checkpoints")
PrintAndLog(&logs, " No check points")
}
}
......
<?php
<<<TC
title: 用户登录
caseId: 100
steps: // @开头的为含验证点的步骤
step1000 // 打开登录页面
step1010 // 输入正确的用户名和密码
@step1020 // 点击'登录'按钮
expects:
#
<@step1020 期望结果, 可以有多行>
TC;
// 此处编写操作步骤代码
echo "#\n"; // 验证点@step1020的标记位,请勿删除
// 期待结果:用户成功登录
// 此处编写上述验证点代码,输出实际结果, 可以有多行
?>
<?php
<<<TC
title: 登录失败账号锁定策略
caseId: 200
steps: // @开头的为含验证点的步骤
step2000 // 连续输入3次错误的密码
@step2010 // 第4次尝试登录
group2100 // 不连续输入3次错误的密码
step2101 // 输入2次错误的密码
step2102 // 输入1次正确的密码
step2103 // 再输入1次错误的密码
@step2104 // 再输入1次正确的密码
expects:
#
111
222
#
aaa
bbb
TC;
// 此处编写操作步骤代码
echo "#\n"; // 验证点@step2010的标记位,请勿删除
echo "111\n";
echo "222\n";
echo "#\n"; // 验证点@step2104的标记位,请勿删除
echo "aaa\n";
echo "bbb\n";
?>
<?php
<<<TC
title: 注册
caseId: 300
steps: // @开头的为含验证点的步骤
expects:
TC;
// 此处编写操作步骤代码
?>
<?php
<<<TC
title: 忘记密码
caseId: 400
steps: // @开头的为含验证点的步骤
expects:
TC;
// 此处编写操作步骤代码
?>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册