citrus-framework

How to create test variable from bean property value in XML test


I need to create a test variable in my XML Citrus test. The variable should be set from a bean property, like this:

        <variable name="zzzz" value="#{beanID.property}"/>

The variable gets created, but the #{beanID.property} does not get evaluated to bean's property value and the variable is set to the string '#{beanID.property}' instead.

The bean property is already available in the test, for example

        <echo>
            <message>My best idea: #{beanID.property}</message>
        </echo>

works as expected. Any other variables which are set using the standard ${...} substitution are created as expected.

No error messages from the framework are generated.


Solution

  • The Spring bean property expression language is not supported by the Citrus Xml test specification. Though a good enhancement idea so maybe worth a feature request and contribution to the framework.

    If you want to use it right now you can also write a custom function that resolves the Spring bean property expression on the fly.

    You can find good documentation about custom functions in Citrus user guide.