+ [misc] Add unit tests for caselibZen::assignCaseParamsForCreateCase() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -445,4 +445,34 @@ class caselibTest
|
||||
'hasLastRunDate' => isset($config->testcase->search['fields']['lastRunDate']) ? 1 : 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assignCaseParamsForCreateCase method.
|
||||
*
|
||||
* @param int $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function assignCaseParamsForCreateCaseTest(int $param): array
|
||||
{
|
||||
$zen = initReference('caselib');
|
||||
$method = $zen->getMethod('assignCaseParamsForCreateCase');
|
||||
$zenInstance = $zen->newInstance();
|
||||
|
||||
// Execute method
|
||||
$method->invoke($zenInstance, $param);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
// Return view variables for verification
|
||||
return array(
|
||||
'caseTitle' => $zenInstance->view->caseTitle ?? '',
|
||||
'type' => $zenInstance->view->type ?? '',
|
||||
'stage' => $zenInstance->view->stage ?? '',
|
||||
'pri' => $zenInstance->view->pri ?? 0,
|
||||
'precondition' => $zenInstance->view->precondition ?? '',
|
||||
'keywords' => $zenInstance->view->keywords ?? '',
|
||||
'stepsCount' => is_array($zenInstance->view->steps ?? array()) ? count($zenInstance->view->steps) : 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 caselibZen::assignCaseParamsForCreateCase();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行caselibTest模块的assignCaseParamsForCreateCaseTest方法
|
||||
- 属性type @feature
|
||||
- 属性pri @3
|
||||
- 属性caseTitle @~~
|
||||
- 属性precondition @~~
|
||||
- 属性keywords @~~
|
||||
- 属性stage @~~
|
||||
- 执行caselibTest模块的assignCaseParamsForCreateCaseTest方法,参数是1
|
||||
- 属性type @feature
|
||||
- 属性pri @1
|
||||
- 属性caseTitle @这个是测试用例1
|
||||
- 属性precondition @这是前置条件1
|
||||
- 属性keywords @这是关键词1
|
||||
- 属性stage @unittest
|
||||
- 执行caselibTest模块的assignCaseParamsForCreateCaseTest方法,参数是2
|
||||
- 属性type @performance
|
||||
- 属性pri @2
|
||||
- 属性caseTitle @这个是测试用例2
|
||||
- 属性precondition @这是前置条件2
|
||||
- 属性keywords @这是关键词2
|
||||
- 属性stage @feature
|
||||
- 执行caselibTest模块的assignCaseParamsForCreateCaseTest方法,参数是3
|
||||
- 属性type @config
|
||||
- 属性pri @3
|
||||
- 属性caseTitle @这个是测试用例3
|
||||
- 属性precondition @这是前置条件3
|
||||
- 属性keywords @这是关键词3
|
||||
- 属性stage @intergrate
|
||||
- 执行caselibTest模块的assignCaseParamsForCreateCaseTest方法,参数是4
|
||||
- 属性type @install
|
||||
- 属性pri @4
|
||||
- 属性caseTitle @这个是测试用例4
|
||||
- 属性precondition @这是前置条件4
|
||||
- 属性keywords @这是关键词4
|
||||
- 属性stage @system
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/caselib.unittest.class.php';
|
||||
|
||||
zenData('case')->loadYaml('case_assigncaseparamsforcreatecase', false, 2)->gen(10);
|
||||
zenData('casestep')->loadYaml('casestep_assigncaseparamsforcreatecase', false, 2)->gen(20);
|
||||
|
||||
su('admin');
|
||||
|
||||
$caselibTest = new caselibTest();
|
||||
|
||||
r($caselibTest->assignCaseParamsForCreateCaseTest(0)) && p('type,pri,caseTitle,precondition,keywords,stage') && e('feature,3,~~,~~,~~,~~');
|
||||
r($caselibTest->assignCaseParamsForCreateCaseTest(1)) && p('type,pri,caseTitle,precondition,keywords,stage') && e('feature,1,这个是测试用例1,这是前置条件1,这是关键词1,unittest');
|
||||
r($caselibTest->assignCaseParamsForCreateCaseTest(2)) && p('type,pri,caseTitle,precondition,keywords,stage') && e('performance,2,这个是测试用例2,这是前置条件2,这是关键词2,feature');
|
||||
r($caselibTest->assignCaseParamsForCreateCaseTest(3)) && p('type,pri,caseTitle,precondition,keywords,stage') && e('config,3,这个是测试用例3,这是前置条件3,这是关键词3,intergrate');
|
||||
r($caselibTest->assignCaseParamsForCreateCaseTest(4)) && p('type,pri,caseTitle,precondition,keywords,stage') && e('install,4,这个是测试用例4,这是前置条件4,这是关键词4,system');
|
||||
@@ -0,0 +1,144 @@
|
||||
---
|
||||
fields:
|
||||
- field: id
|
||||
note: ID
|
||||
range: 1-400
|
||||
- field: product
|
||||
note: 产品ID
|
||||
range: 1-100{4}
|
||||
- field: branch
|
||||
note: 分支ID
|
||||
range: 0
|
||||
- field: execution
|
||||
note: 执行ID
|
||||
range: 101-700{4}
|
||||
- field: lib
|
||||
note: 所属库
|
||||
range: 0
|
||||
- field: module
|
||||
note: 所属模块
|
||||
range: 0
|
||||
- field: path
|
||||
note: ""
|
||||
range: "0"
|
||||
- field: story
|
||||
note: 相关需求
|
||||
range: 2-400:4{4}
|
||||
- field: storyVersion
|
||||
note: 需求版本
|
||||
range: "1"
|
||||
- field: title
|
||||
note: 用例标题
|
||||
range: 1-400
|
||||
prefix: 这个是测试用例
|
||||
- field: precondition
|
||||
note: 前置条件
|
||||
range: 1-400
|
||||
prefix: 这是前置条件
|
||||
- field: keywords
|
||||
note: 关键词
|
||||
range: 1-400
|
||||
prefix: 这是关键词
|
||||
- field: pri
|
||||
note: 优先级
|
||||
range: 1-4
|
||||
- field: type
|
||||
note: 用例类型
|
||||
range: feature,performance,config,install,security,interface,other
|
||||
- field: auto
|
||||
note: 是否是自动化测试用例
|
||||
range: "no"
|
||||
- field: frame
|
||||
note: 自动化测试框架
|
||||
range: ""
|
||||
- field: stage
|
||||
note: 适用阶段
|
||||
range: unittest,feature,intergrate,system,smoke,bvt
|
||||
- field: howRun
|
||||
note: 测试方式
|
||||
range: ""
|
||||
- field: scriptedBy
|
||||
note: 脚本由谁创建
|
||||
range: ""
|
||||
- field: scriptedDate
|
||||
note: 脚本创建日期
|
||||
range: (M)-(w)
|
||||
type: timestamp
|
||||
postfix: ""
|
||||
format: YY/MM/DD
|
||||
- field: scriptStatus
|
||||
note: 脚本状态
|
||||
range: ""
|
||||
- field: scriptLocation
|
||||
note: 脚本地址
|
||||
range: ""
|
||||
- field: status
|
||||
note: 用例状态
|
||||
range: wait,normal,blocked,investigate
|
||||
- field: subStatus
|
||||
note: 子状态
|
||||
range: ""
|
||||
- field: color
|
||||
note: 标题颜色
|
||||
- field: frequency
|
||||
note: 使用频率
|
||||
range: 1-3
|
||||
- field: order
|
||||
note: 排序
|
||||
range: 5-200:5
|
||||
- field: openedBy
|
||||
note: 由谁创建
|
||||
range: 1-100
|
||||
prefix: test
|
||||
- field: openedDate
|
||||
note: 创建日期
|
||||
range: -:600
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: reviewedBy
|
||||
note: 由谁评审
|
||||
range: admin
|
||||
- field: reviewedDate
|
||||
note: 评审时间
|
||||
range: -:300
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: lastEditedBy
|
||||
note: 最后修改者
|
||||
range: admin
|
||||
- field: lastEditedDate
|
||||
note: 修改日期
|
||||
range: -:300
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: version
|
||||
note: 用例版本
|
||||
range: "1"
|
||||
- field: linkCase
|
||||
note: 相关用例
|
||||
range: 0
|
||||
- field: fromBug
|
||||
note: 来源Bug
|
||||
range: 0
|
||||
- field: fromCaseID
|
||||
note: ""
|
||||
range: 0
|
||||
- field: fromCaseVersion
|
||||
note: ""
|
||||
range: 1
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: 0{9950},1{50}
|
||||
- field: lastRunner
|
||||
note: 执行人
|
||||
range: 1-100
|
||||
prefix: test
|
||||
- field: lastRunDate
|
||||
note: 执行时间
|
||||
range: -:500
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: lastRunResult
|
||||
note: 结果
|
||||
range: pass,fail,``{2}
|
||||
...
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
fields:
|
||||
- field: id
|
||||
note: ID
|
||||
range: 1-400
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: parent
|
||||
note: 上级ID
|
||||
range: "0"
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: case
|
||||
note: 所属用例ID
|
||||
range: 1-400
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: version
|
||||
note: 用例版本
|
||||
range: "1"
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: type
|
||||
note: 用例类型
|
||||
range: step
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: desc
|
||||
note: 用例步骤
|
||||
range: 1-10000
|
||||
prefix: 用例步骤描述
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: expect
|
||||
note: 预期
|
||||
range: 1-10000
|
||||
prefix: 这是用例预期结果
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
...
|
||||
Reference in New Issue
Block a user