Before and After Scopes | MuleSoft Documentation
# Before and After Scopes
Anypoint Code Builder 
Anypoint Studio 
## Before Suite Scope
The MUnit Before Suite contains code that is meant to be executed before the whole suite. The Before Suite has one execution rule: Run before all the tests, just once.
For example, suppose you have an MUnit Test Suite file with four tests. The code inside an MUnit Before Suite runs just once, before your four tests.
You can only use one Before Suite scope per MUnit test suite.   
---  
Before Suite example
```
<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>
```

Note that the `before-suite` is located outside the MUnit test. One instance in which the MUnit Before Suite is useful is when you need to set up a test environment before all tests run.
When you place a before-suite in the Anypoint Studio canvas, the scope locates outside the MUnit test.
## After Suite Scope
The MUnit After Suite is a scope. It can contain code that is meant to be executed after the whole suite. The After suite has one execution rule: Run after all the tests, just once.
For instance, let’s suppose you have an MUnit Test Suite File with four tests. The code inside an MUnit After Suite, runs just once, after all your tests.
You can only use one After Suite scope per MUnit test suite.   
---  
After Suite example
```
<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 >
```

Note that the after-suite is located outside the MUnit test. One instance in which the MUnit After Suite is useful is when you need to tear down a test environment after the whole test runs.
When you place an after-suite in the Anypoint Studio canvas, the scope locates outside the MUnit test.
## Before Test Scope
The MUnit Before Test Scope contains code that is meant to be executed before each test. Each Before Test scope follows the same execution rule: Run before each test.
For instance, let’s suppose you have an MUnit Test Suite file with four tests. The code inside an MUnit Before test runs before each of your four tests; it runs four times.
You can only use one Before Test scope per MUnit test suite.   
---  
Before Test example
```
<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>
```

Note that the `before.test` is located outside the MUnit test. One instance in which the MUnit Before Test is useful is when you need to set up a test environment before each test run, like creating a file or setting a variable that will be consumed in each test.
When you place an before-test in the Anypoint Studio canvas, the scope locates outside the MUnit test.
## After Test Scope
The MUnit After Test Scope contains code that is meant to be executed after each test. Each After Test scope follows the same execution rule: Run after each test.
For instance, let’s suppose you have an MUnit Test Suite file with four tests. The code inside an MUnit After Test runs after each of your four tests; it runs four times.
You can only use one After Test scope per MUnit test suite.   
---  
After Test example
```
<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>
```

Note that the `after.test` is located outside the MUnit test. One instance in which the MUnit After test is useful is when you need to tear down a test environment after the whole test runs.
When you place an after-test in the Anypoint Studio canvas, the scope locates outside the MUnit test.
## Before Suite Reference
Attribute Name | Description  
---|---  
Defines the name of the Before suite. The name must be unique inside the suite.  
`description` | Describes the actions performed.  
## After Suite Reference
Attribute Name | Description  
---|---  
Defines the name of the After suite. The name must be unique inside the suite.  
`description` | Describes the actions performed.  
## Before Test Reference
Attribute Name | Description  
---|---  
Defines the name of the Before test. The name must be unique inside the suite.  
`description` | Describes the actions performed.  
## After Test Reference
Attribute Name | Description  
---|---  
Defines the name of the After test. The name must be unique inside the suite.  
`description` | Describes the actions performed.