Search code examples
concordion

Concordion print a variable string in green


In my java class I've defined an array of Strings and I can get any of them providing its index:

         <span c:execute="#errStr=#page.getDictionaryString(2)"/>

so #errStr contains my String

in the test I receive the String to verify, in another var (#str)

         <span c:execute="#str = #e.get()"/>

Now, I can have a green "true" if they are the same:

         <span c:assertTrue="#str.equals(#errStr)">true</span>

Anyhow "true" adds less value when reading the output, I'd like to read there (in green) the value of #str (or #errStr that is the same).

Is it possible ?

If that is not possible is it possible to have at least the value of #str in normal color so that I'll then add a green "true" near it?


Solution

  • This use case is not supported out of the box, since Concordion encourages you to define the expected values in the specification, rather than deriving values dynamically. If possible, you should look to move the expected value into the specification.

    If this is not possible, you can write a custom command through the use of Concordion extensions that does exactly what you want.

    Or the following will give you an approximation:

    <span c:assertTrue="#str.equals(#errStr)"><span c:echo="#str"/></span>
    

    The echo command outputs the value of an expression to the specification. This will print the value of #str, and colour the output green. On failure the value of #str will be red and struckthrough, with =false printed next to it (this is where a custom command would improve the output).