diff --git a/module/testcase/model.php b/module/testcase/model.php index 061358bc90..db7d229c58 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -1637,13 +1637,14 @@ class testcaseModel extends model } /** - * Summary cases + * 获取用例总结。 + * Summary cases. * - * @param array $cases + * @param array $cases * @access public * @return string */ - public function summary($cases) + public function summary(array $cases): string { $executed = 0; foreach($cases as $case) diff --git a/module/testcase/test/model/summary.php b/module/testcase/test/model/summary.php new file mode 100644 index 0000000000..6db5f4b832 --- /dev/null +++ b/module/testcase/test/model/summary.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +gen('20'); +zdTable('user')->gen('1'); + +su('admin'); + +/** + +title=测试 testcaseModel->summary(); +cid=1 +pid=1 + +*/ + +$caseIdList = array('1,2,3', '4,5,6', '7,8,9', '10,11,12', '13,14,15', ''); + +$testcase = new testcaseTest(); + +r($testcase->summaryTest($caseIdList[0])) && p() && e('本页共 3 个顶级场景,2 个独立用例。'); // 测试获取case 1 2 3 的总结信息 +r($testcase->summaryTest($caseIdList[1])) && p() && e('本页共 3 个顶级场景,2 个独立用例。'); // 测试获取case 4 5 6 的总结信息 +r($testcase->summaryTest($caseIdList[2])) && p() && e('本页共 3 个顶级场景,1 个独立用例。'); // 测试获取case 7 8 9 的总结信息 +r($testcase->summaryTest($caseIdList[3])) && p() && e('本页共 3 个顶级场景,1 个独立用例。'); // 测试获取case 10 11 12 的总结信息 +r($testcase->summaryTest($caseIdList[4])) && p() && e('本页共 3 个顶级场景,2 个独立用例。'); // 测试获取case 13 14 15 的总结信息 +r($testcase->summaryTest($caseIdList[5])) && p() && e('本页共 0 个顶级场景,0 个独立用例。'); // 测试获取case 空 的总结信息 diff --git a/module/testcase/test/testcase.class.php b/module/testcase/test/testcase.class.php index 1859a72411..b337e7a3c8 100644 --- a/module/testcase/test/testcase.class.php +++ b/module/testcase/test/testcase.class.php @@ -1239,4 +1239,21 @@ class testcaseTest if(dao::isError()) return dao::getError(); return $moduleID; } + + /** + * 测试获取用例总结。 + * Test summary cases. + * + * @param string $caseIdList + * @access public + * @return string + */ + public function summaryTest(string $caseIdList): string + { + $caseIdList = explode(',', $caseIdList); + $cases = $this->objectModel->getByList($caseIdList); + $moduleID = $this->objectModel->summary($cases); + if(dao::isError()) return dao::getError(); + return $moduleID; + } } diff --git a/test/data/case.yaml b/test/data/case.yaml index 2296e47833..43cbe4b9ac 100644 --- a/test/data/case.yaml +++ b/test/data/case.yaml @@ -143,4 +143,4 @@ fields: format: "YYYY-MM-DD hh:mm:ss" - field: lastRunResult note: "结果" - range: [pass,fail] + range: pass,fail,``{2}