Hear from Salesforce leaders on how to create and deploy Agentforce agents.
Contact Us 1-800-596-4880

Parameterized

logo acb active Anypoint Code Builder

logo studio active Anypoint Studio

A parameterized test suite runs the same tests but with different inputs.

The test suite parameterization is defined at a configuration level as follows:

<munit:config>
    <munit:parameterizations>
        <munit:parameterization name="firstParameterization">
            <munit:parameters>
                <munit:parameter propertyName="name" value="Robert"/>
                <munit:parameter propertyName="lastname" value="Plant"/>
            </munit:parameters>
        </munit:parameterization>
        <munit:parameterization name="secondParameterization">
            <munit:parameters>
                <munit:parameter propertyName="name" value="Jimmy"/>
                <munit:parameter propertyName="lastname" value="Page"/>
            </munit:parameters>
        </munit:parameterization>
    </munit:parameterizations>
</munit:config>
xml

The Test Suite runs twice: Firstly, with the firstParameterization parameters. Secondly, with the secondParameterization parameters.

For example, if you have a test that sets a payload for a flow and expects a result:

Parameterization Example

Parameterization from File

To use the same parameterized values on different test suites, you must save your parameterizations values in a YAML file in the /test/resources directory of your Mule application project:

parameterizations.yaml Example
firstParameterization:
    name: "Robert"
    lastname: "Plant"

secondParameterization:
    name: "Jimmy"
    lastname: "Page"
yaml

And reference it from your test suite configuration:

Example Parameterization From File
<munit:config>
    <munit:parameterizations file="parameterizations.yaml" />
</munit:config>
xml

You can combine both methods to add parameterized values to a test suite:

Example Parameterization From File and in the Test Suite Configuration
<munit:config name="parameterization-from-file-test.xml">
    <munit:parameterizations file="parameterizations.yaml" >
        <munit:parameterization name="thirdParameterization">
            <munit:parameters>
                <munit:parameter propertyName="name" value="John"/>
                <munit:parameter propertyName="lastname" value="Bonham"/>
            </munit:parameters>
        </munit:parameterization>
    </munit:parameterizations>
</munit:config>
xml

If you define the same parameterization key in a YAML file and your test suite configuration, the test suite parameterization overrides your YAML parameterization.