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.
|
Use a Before Suite scope to set up state that every test in the suite shares, such as seeding an in-memory database, starting a server utility, or storing values that the tests read. In the example, the jobtitlelookup.csv file creates the table and its initial contents when the database server starts, and the Before Suite adds one shared row that all tests in the suite query:
Before Suite example
<dbserver:config name="MUnit_DB_Server_Config">
<dbserver:connection csv="jobtitlelookup.csv" database="DATABASE_NAME"
connectionStringParameters="MODE=MySQL" />
</dbserver:config>
<munit:before-suite name="before-suite" description="Adds a shared row for the whole suite">
<dbserver:execute config-ref="MUnit_DB_Server_Config"
sql="INSERT INTO jobtitlelookup VALUES ('Support Engineer','10','SUP');" />
</munit:before-suite>
<munit:test name="munit.test" description="Test">
<!-- Every test in this suite can query the row added by the before-suite -->
</munit:test>
|
|
The before-suite scope is located outside the MUnit test, so the insert runs once before the first test instead of once per test.
|
When you place a before-suite in the Anypoint Studio canvas, the scope locates outside the MUnit test.