From 39d39bc4d890c7380bf4577ec4b16a060c8cb930 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 19 Dec 2017 09:59:40 +0800 Subject: [PATCH] * finish task #3444. --- module/testcase/config.php | 2 +- module/testcase/control.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/module/testcase/config.php b/module/testcase/config.php index 40c08e6a09..d246cfc859 100644 --- a/module/testcase/config.php +++ b/module/testcase/config.php @@ -19,7 +19,7 @@ $config->testcase->export->listFields = array('type', 'stage', 'pri', 'status' $config->testcase->exportFields = ' id, product, branch, module, story, - title, precondition, stepDesc, stepExpect, keywords, + title, precondition, stepDesc, stepExpect, real, keywords, pri, type, stage, status, bugsAB, resultsAB, stepNumberAB, lastRunResult, openedBy, openedDate, lastEditedBy, lastEditedDate, version, linkCase'; diff --git a/module/testcase/control.php b/module/testcase/control.php index c8c7ee1581..0d1df328f8 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -1106,6 +1106,17 @@ class testcase extends control } } + $stmt = $this->dao->select('*')->from(TABLE_TESTRESULT) + ->where('`case`')->in(array_keys($cases)) + ->beginIF($taskID)->andWhere('run')->eq($taskID)->fi() + ->orderBy('id_desc') + ->query(); + $results = array(); + while($result = $stmt->fetch()) + { + if(!isset($results[$result->case])) $results[$result->case] = unserialize($result->stepResults); + } + /* Get users, products and projects. */ $users = $this->loadModel('user')->getPairs('noletter'); $products = $this->loadModel('product')->getPairs('nocode'); @@ -1134,7 +1145,7 @@ class testcase extends control $relatedModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($relatedModuleIdList)->fetchPairs(); $relatedStories = $this->dao->select('id,title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs(); $relatedCases = $this->dao->select('id, title')->from(TABLE_CASE)->where('id')->in($relatedCaseIdList)->fetchPairs(); - $relatedSteps = $this->dao->select('parent,`case`,version,type,`desc`,expect')->from(TABLE_CASESTEP)->where('`case`')->in(@array_keys($cases))->orderBy('version desc,id')->fetchGroup('case'); + $relatedSteps = $this->dao->select('id,parent,`case`,version,type,`desc`,expect')->from(TABLE_CASESTEP)->where('`case`')->in(@array_keys($cases))->orderBy('version desc,id')->fetchGroup('case', 'id'); $relatedModules = array('0' => '/') + $relatedModules; $cases = $this->testcase->appendData($cases); @@ -1142,6 +1153,9 @@ class testcase extends control { $case->stepDesc = ''; $case->stepExpect = ''; + $case->real = ''; + $result = isset($results[$case->id]) ? $results[$case->id] : array(); + if($case->lastRunResult == 'fail' and !isset($relatedSteps[$case->id]) and !empty($result)) $case->real = $result[0]['real']; if(isset($relatedSteps[$case->id])) { $i = $childId = 0; @@ -1162,6 +1176,7 @@ class testcase extends control $sign = (in_array($this->post->fileType, array('html', 'xml'))) ? '
' : "\n"; $case->stepDesc .= $stepId . ". " . $step->desc . $sign; $case->stepExpect .= $stepId . ". " . $step->expect . $sign; + if($case->lastRunResult == 'fail') $case->real .= $stepId . ". " . (isset($result[$step->id]) ? $result[$step->id]['real'] : '') . $sign; $childId ++; } }