* Add unit test for metric.
This commit is contained in:
+2
-2
@@ -30,9 +30,9 @@ class count_of_delayed_finished_execution_which_finished extends baseCalc
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
if(empty($row->closedDate) or empty($row->firstEnd)) return false;
|
||||
if(empty($row->closedDate) || empty($row->firstEnd)) return false;
|
||||
|
||||
if($row->status == 'closed' and $row->closedDate <= $row->firstEnd) $this->result ++;
|
||||
if($row->status == 'closed' and $row->closedDate > $row->firstEnd) $this->result ++;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('project')->config('execution', $useCommon = true, $levels = 4)->gen(100, false);
|
||||
zdTable('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('project')->config('execution_delayed', $useCommon = true, $levels = 4)->gen(100, false);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('project')->config('execution_delayed', $useCommon = true, $levels = 4)->gen(100, false);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_delayed_finished_execution_which_finished
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
r($calc->getResult()) && p('') && e('16'); // 测试分组数
|
||||
@@ -21,8 +21,4 @@ fields:
|
||||
range: "20110101 000000-20210101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: firstEnd
|
||||
range: "20010101 000000-20110101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
...
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: zt_project
|
||||
author: qixinzhi
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 11-10000
|
||||
- field: project
|
||||
range: 1-10{20}
|
||||
- field: type
|
||||
range: sprint
|
||||
- field: status
|
||||
range: closed{4},doing{3},suspended{2},wait{1}
|
||||
- field: deleted
|
||||
range: 0{10},1{10}
|
||||
- field: openedDate
|
||||
range: "20100101 000000-20200101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: closedDate
|
||||
range: "20110101 000000-20210101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: firstEnd
|
||||
range: "20010101 000000-20110101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
...
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: zt_project
|
||||
author: qixinzhi
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 11-10000
|
||||
- field: project
|
||||
range: 1-10{20}
|
||||
- field: type
|
||||
range: sprint
|
||||
- field: status
|
||||
range: closed{4},doing{3},suspended{2},wait{1}
|
||||
- field: deleted
|
||||
range: 0{10},1{10}
|
||||
- field: openedDate
|
||||
range: "20100101 000000-20200101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: closedDate
|
||||
range: "20110101 000000-20210101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: firstEnd
|
||||
range: "20210101 000000-20131101 000000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
...
|
||||
Reference in New Issue
Block a user