testcase
testcase 允许你的应用能够直接调用创建测试用例、打开测试用例详情。
导入:
typescript
import { testcase } from '@pc-nexus/capabilities';内置方法:
| API | 描述 |
|---|---|
openCreate | 打开测试用例创建弹窗 |
openDetail | 打开测试用例详情弹窗 |
openCreate
openCreate 打开测试用例创建弹窗,根据传入的默认值展示数据。
函数签名
typescript
function openCreate(options?: TestcaseOpenCreateOptions): Promise<void>;
export interface TestcaseOpenCreateOptions {
defaultValues?: {
title?: string;
library_id?: string;
};
onSuccess?: (payload: Testcase) => void;
}
export interface Testcase {
id: string;
short_id: string;
identifier: string;
title: string;
}参数
| 名称 | 描述 |
|---|---|
options | 打开测试用例创建弹窗的配置项(见下方详细说明) |
TestcaseOpenCreateOptions 类型定义如下:
| 名称 | 描述 |
|---|---|
defaultValues | 创建测试用例设置一些属性默认值 |
onSuccess | 测试用例创建成功后回调函数 |
onSuccess 类型定义如下:
| 名称 | 描述 |
|---|---|
id | 测试用例的 id |
title | 测试用例的标题 |
short_id | 测试用例的短 id |
identifier | 测试用例的编号 |
返回值
空
示例
typescript
import { testcase } from '@pc-nexus/capabilities';
testcase.openCreate({
defaultValues: {
title: '新用例',
},
onSuccess: (payload) => {
console.log('create test case success', payload);
},
});openDetail
openDetail 打开测试用例详情弹窗。
函数签名
typescript
function openDetail(identifier: string): Promise<void>;参数
| 名称 | 描述 |
|---|---|
identifier | 测试用例的编号或测试用例 id |
返回值
空
示例
typescript
import { testcase } from '@pc-nexus/capabilities';
testcase.openDetail('69df016092c2c86322c1890c');