> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/autify-university/advanced/cleanup/cleanup-steps.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# クリーンアップステップ

{% hint style="info" %}
⚠️ クリーンアップステップは、AdvancedおよびEnterpriseプラン、および同等のプランをご契約のお客様がご利用いただけます。
{% endhint %}

## 概要

クリーンアップステップは、たとえ先行するステップで失敗が起こったとしても、テスト実行の最後に必ず実行される特別なステップです。特に、次のテスト実行が同じ条件で行われるよう、テスト実行中に生成されたデータを削除するなど、結果の成否によらずテストの最後に必ず実行する必要のあるステップがある場合にとても便利です。

## クリーンアップステップを有効化する

クリーンアップステップは既存のシナリオに追加できますが、はじめは表示されていません。機能を有効化するには、シナリオ詳細画面のオプションタブを開き、「クリーンアップステップを表示する」にチェックを入れます。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-d2d168ca7865728f894a20b45befb539fb85d589%2FScreen%20Shot%202023-09-14%20at%2020.16.44.png?alt=media)

シナリオのタブに戻ると、クリーンアップステップのセクションが画面の下部に追加されています。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-868f5185fb3572ffa17753f808edcdf4205e38c1%2FScreen%20Shot%202023-09-14%20at%2020.17.02.png?alt=media)

## クリーンアップステップを作成する

クリーンアップステップの作りかたには、二つの方法があります。

### 既存のステップをドラッグ&ドロップしてクリーンアップステップにする

もし、既にシナリオ内にクリーンアップステップとして利用できるようなステップがある場合は、クリーンアップステップの領域にステップをドラッグ&ドロップすることができます。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-96fd28d1ede72fd5696dc282405ed52eac43050b%2FScreen%20Shot%202023-09-15%20at%2011.04.03\(1\).png?alt=media)

### クリーンアップステップを新規にレコーディングする

クリーンアップステップは、1からレコーディングすることも可能です。なお、レコーディングはシナリオのステップ1のURLから始まる点にご注意ください。異なるURLからクリーンアップステップをレコーディングしたい場合には、クリーンアップステップの冒頭に「URLに移動」ステップを追加してください。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-9366ffd95bdee517c52d6dc9fa862fd9083bac23%2FScreen%20Shot%202023-09-15%20at%2011.02.58.png?alt=media)

## クリーンアップステップを持つシナリオを実行する

クリーンアップステップは、通常のステップと同様に実行できます。しかし、どのようにステップが実行されるかが異なります。

### シナリオ

ステップ1から3が通常のステップ（「このステップが失敗した時」は「テストを終了する」に設定されている）で、ステップ4から5はクリーンアップステップとなっている例では

* すべて成功した場合、ステップは `1` → `2` → `3` → `4` → `5` の順で実行されます。
* もしシナリオがステップ2で失敗した場合、 `1` → `2` → `4` → `5` の順で実行されます。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-d15b45682364c7c926170734d2a21bfd59e49286%2FScreen%20Shot%202023-09-22%20at%2016.41.48.png?alt=media)

### テスト結果

テスト結果詳細画面は、二つのパートに分けられます。通常のステップと、クリーンアップステップです。

#### 成功したテスト結果

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-c3b9a254092a148ceb991eb6a753a6904c1d634c%2FScreen%20Shot%202023-09-15%20at%2010.57.56.png?alt=media)

#### テストが失敗しクリーンアップステップが実行されたテスト結果

通常のステップが途中で失敗しても、クリーンアップステップは実行されます。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-5ad121f5f300cb83b51eb90fb7919bd934e852e8%2FScreen%20Shot%202023-09-15%20at%2010.58.15.png?alt=media)

#### クリーンアップステップが失敗したテスト結果

クリーンアップステップ自体も失敗することがあります。テストは失敗とみなされますが、エラーメッセージの領域は黄色にハイライトされ、通常のステップの失敗と見分けがつきやすくなっています。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-7c9a294926a7b943c084e3c6787c3911863f6db7%2FScreen%20Shot%202023-09-15%20at%2010.58.46.png?alt=media)

## 活用のコツ

### 冒頭に「URLに移動」ステップを追加する

クリーンアップステップは最初のURLを指定しなくても動作します。一方、クリーンアップステップが常に特定のURLから始まるようにしたい場合は「URLに移動」ステップを追加するようにしてください。

### データをクリアするAPIのエンドポイントを用意する

テスト中に生成されたデータをクリーンアップするベストプラクティスの一つには、テストデータをクリアするようなAPIのエンドポイントを用意しJSステップから呼び出す方法があります。また、よりシンプルに、アプリケーションの操作でデータを消したり元の状態に戻したりするステップをレコーディングするのもよいでしょう。

{% hint style="warning" %}
**注意**

この機能はAdvanced・Enterprise、および同等のご契約プランで提供されるため、機能を利用できないプランへダウングレードするとクリーンアップステップは表示されなくなります。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/autify-university/advanced/cleanup/cleanup-steps.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
