* Add unit test for metrics.

This commit is contained in:
zhouxin
2023-07-18 11:20:02 +08:00
parent bf683f3207
commit f3f5477e18
3 changed files with 47 additions and 12 deletions
@@ -15,17 +15,8 @@ title=count_of_invalid_story_in_product
timeout=0
cid=1
- 测试分组数 @14
- 测试产品1无效需求数
- 第0条的value属性 @1
- 第1条的value属性 @1
- 第2条的value属性 @1
- 测试不存在产品的无效需求数 @0
*/
r(count($calc->getResult())) && p('') && e('14'); // 测试分组数
r($calc->getResult(array('product' => '1,2,5'))) && p('0:value;1:value;2:value') && e('1;1;1'); // 测试产品1无效需求数
r($calc->getResult(array('product' => '999,1000'))) && p('') && e('0'); // 测试不存在产品的无效需求数
r(count($calc->getResult())) && p('') && e('21'); // 测试分组数
r($calc->getResult(array('product' => '2,3,4'))) && p('0:value;1:value;2:value') && e('1;2;1'); // 测试产品1无效需求数
r($calc->getResult(array('product' => '999,1000'))) && p('') && e('0'); // 测试不存在产品的无效需求数
@@ -0,0 +1,22 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('story')->gen(100);
zdTable('product')->gen(100);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_story_in_product
timeout=0
cid=1
*/
r(count($calc->getResult())) && p('') && e('25'); // 测试分组数
r($calc->getResult(array('product' => '2,3,4'))) && p('0:value;1:value;2:value') && e('2;2;2'); // 测试产品1需求数
r($calc->getResult(array('product' => '999,1000'))) && p('') && e('0'); // 测试不存在产品的需求数
@@ -0,0 +1,22 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('story')->gen(100);
zdTable('product')->gen(100);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_valid_story_in_product
timeout=0
cid=1
*/
r(count($calc->getResult())) && p('') && e('18'); // 测试分组数
r($calc->getResult(array('product' => '2,4,5'))) && p('0:value;1:value') && e('1;1'); // 测试产品1有效需求数
r($calc->getResult(array('product' => '999,1000'))) && p('') && e('0'); // 测试不存在产品的有效需求数