---
url: /reference/interface/capabilities/testcase.md
---

# testcase

`testcase` 允许你的应用能够直接调用创建测试用例、打开测试用例详情。

导入：

```typescript
import { testcase } from '@pc-nexus/capabilities';
```

内置方法：

## 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;
}
```

### 参数

`TestcaseOpenCreateOptions` 类型定义如下：

`onSuccess` 类型定义如下：

### 返回值

空

### 示例

```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>;
```

### 参数

### 返回值

空

### 示例

```typescript
import { testcase } from '@pc-nexus/capabilities';

testcase.openDetail('69df016092c2c86322c1890c');
```
