---
schema_version: "1"
id: df93600e51451565af9f2f09a0d961da56478153388f7436eb3cb9b11f5fb84f
title: Before および After スコープ
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/munit/2.3/before-after-scopes-reference.md
canonical_url: https://docs.mulesoft.com/jp/munit/2.3/before-after-scopes-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0eeeacca9f2ba54c459e062b1f8a1dd7bf0ce78ed0a973311b5132568e652cb0
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# Before および After スコープ

## [](#before-suite-scope)Before Suite スコープ

MUnit Before Suite には、スイート全体の前に実行されることを意図したコードが含まれます。 Before Suite には 1 つの実行ルールがあり、すべてのテストの前に 1 回のみ実行されます。

たとえば、4 つのテストを含む MUnit テストスイートファイルがあるとします。MUnit Before Suite 内のコードは、4 つのテストの前に 1 回のみ実行されます。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">MUnit テストスイートごとに使用できる Before Suite スコープは 1 つのみです。</td></tr></tbody></table>

Before Suite の例

```xml
<munit:before-suite name="before-suite" description="Executes a before suite">
  <!-- some mule code here -->
</munit:before-suite >

<munit:test name="munit.test" description="Test">
  <!-- some more mule code here -->
</munit:test>
```

`before-suite`​ は MUnit テストの外側にあります。MUnit Before Suite が役立つ 1 つの例は、すべてのテストを実行する前にテスト環境をセットアップする必要がある場合です。

Anypoint Studio キャンバスに before-suite を配置すると、スコープは MUnit テストの外側に配置されます。

## [](#after-suite-scope)After Suite スコープ

MUnit After Suite はスコープです。スイート全体の後に実行されることを意図したコードを含めることができます。After Suite には 1 つの実行ルールがあり、すべてのテストの後に 1 回のみ実行されます。

たとえば、4 つのテストを含む MUnit テストスイートファイルがあるとします。MUnit After Suite 内のコードは、すべてのテストの後に 1 回のみ実行されます。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">MUnit テストスイートごとに使用できる After Suite スコープは 1 つのみです。</td></tr></tbody></table>

After Suite の例

```xml
<munit:before-suite name="before.suite" description="A description">
  <!-- some mule code here -->
</munit:before-suite >

<munit:test name="munit.test" description="Test">
  <!-- some more mule code here -->
</munit:test>

<munit:after-suite  name="after.suite" description="A description">
  <!-- some Mule code here -->
</munit:after-suite >
```

after-suite は MUnit テストの外側にあります。MUnit After Suite が役立つ 1 つの例は、テスト全体を実行した後にテスト環境を削除する必要がある場合です。

Anypoint Studio キャンバスに after-suite を配置すると、スコープは MUnit テストの外側に配置されます。

## [](#before-test-scope)Before Test スコープ

MUnit Before Test スコープには、各テストの前に実行されることを意図したコードが含まれます。各 Before Test スコープは同じ実行ルールに従い、各テストの前に実行されます。

たとえば、4 つのテストを含む MUnit テストスイートファイルがあるとします。MUnit Before Test 内のコードは、4 つのテストそれぞれの前に実行され、4 回実行されます。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">MUnit テストスイートごとに使用できる Before Test スコープは 1 つのみです。</td></tr></tbody></table>

Before Test の例

```xml
<munit:before-test name="before.test" description="A description">
  <!-- some mule code here -->
</munit:before-test>

<munit:test name="munit.test" description="Test">
  <!-- some more mule code here -->
</munit:test>
```

`before.test`​ は MUnit テストの外側にあります。MUnit Before Test が役立つ 1 つの例は、各テストを実行する前に、各テストでファイルを作成したり、コンシュームされる変数を設定したりするなどのテスト環境をセットアップする必要がある場合です。

Anypoint Studio キャンバスに before-test を配置すると、スコープは MUnit テストの外側に配置されます。

## [](#after-test-scope)After Test スコープ

MUnit After Test スコープには、各テストの後に実行されることを意図したコードが含まれます。各 After Test スコープは同じ実行ルールに従い、各テストの後に実行されます。

たとえば、4 つのテストを含む MUnit テストスイートファイルがあるとします。MUnit After Test 内のコードは、4 つのテストそれぞれの後に実行され、4 回実行されます。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">MUnit テストスイートごとに使用できる After Test スコープは 1 つのみです。</td></tr></tbody></table>

After Test の例

```xml
<munit:before-test name="before.test" description="A description">
  <!-- some mule code here -->
</munit:before-test>

<munit:test name="munit.test" description="Test">
  <!-- some more mule code here -->
</munit:test>

<munit:after-test  name="after.test" description="A description">
  <!-- some mule code here -->
</munit:after-test>
```

`after.test`​ は MUnit テストの外側にあります。MUnit After Test が役立つ 1 つの例は、テスト全体を実行した後にテスト環境を削除する必要がある場合です。

Anypoint Studio キャンバスに after-test を配置すると、スコープは MUnit テストの外側に配置されます。

## [](#before-suite-リファレンス)Before Suite リファレンス

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">属性名</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Before Suite の名前を定義します。この名前は、スイート内で一意である必要があります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>description</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">実行されるアクションを説明します。</p></td>
</tr>
</tbody>
</table>

## [](#after-suite-リファレンス)After Suite リファレンス

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">属性名</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">After Suite の名前を定義します。この名前は、スイート内で一意である必要があります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>description</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">実行されるアクションを説明します。</p></td>
</tr>
</tbody>
</table>

## [](#before-test-リファレンス)Before Test リファレンス

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">属性名</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Before Test の名前を定義します。この名前は、スイート内で一意である必要があります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>description</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">実行されるアクションを説明します。</p></td>
</tr>
</tbody>
</table>

## [](#after-test-リファレンス)After Test リファレンス

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">属性名</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">After Test の名前を定義します。この名前は、スイート内で一意である必要があります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>description</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">実行されるアクションを説明します。</p></td>
</tr>
</tbody>
</table>