Kass
Kass

Reputation: 1

Concordion: How get the parameter value inside #TEXT

I am using Concordion to test some java components. I will write something like

  <pre concordion:execute="someFunction(#TEXT, #a)">
   { 
    id:123,
    name:<span concordion:echo="#b"/>
   }  
  </pre>   

I want to value of #b is calculated and substituted dynamically. But instead of value #b in someFunction comes an empty string. Similarly, if use

name:<span concordion:execute="getBValue()"/>

If someone has done something like this, could you please help.

Thanks.

Upvotes: 0

Views: 1015

Answers (3)

user3632158
user3632158

Reputation: 287

I think Concordion was not design for the purpose of this use case. It is not a template engine. You can transfer the text elements of your specification as input into your automated tests. Additionally, you can use the values inside your specifications as reference to compare the actual outputs of the system under test.

When you want to transfer the result of some method getBValue() into another method someFunction() you have probably several option:

  1. What about calling getBValue() inside your someFunction()?
  2. Or you could transfer the result of getBValue() into a variable and call some Function with this variable:

<pre concordion:execute="someFunction(#TEXT, #a, #b)">
   { 
    id:123,
    name:placeholder-for-value-b
   }  
</pre>

Then inside of someFunction() you could replace the placeholder:

public void someFunction(String text, String aValue, String bValue) {
  text.replace("placeholder-for-value-b", bValue);
  //continue logic of someFunction
}

Upvotes: 1

user3632158
user3632158

Reputation: 287

Could your problem be related with the html structure? When you are using nested elements such as

<pre concordion:execute=...> <span concordion:assert-equals=...>...</span> <span concordion:set=...>...</span> </pre>

Concordion uses the following execution order:

  1. all "standard" commands such as set, echo, etc.
  2. the execute command
  3. assert commands such as assert-equals

This is the way Concordion handles unusual sentence structures.

What about putting the execute-command inside a dedicated span-tag?

<pre> <span concordion:execute=...>...</span> <span concordion:echo=...></span> </pre>

Upvotes: 0

user3632158
user3632158

Reputation: 287

you could use the execute command to initialize the variable #name:

<span concordion:execute="#name=getBValue()"/>

followed by the echo command:

name: <span concordion:echo="name" />

or have you tried to call your method directly within the echo command?

name: <span concordion:echo="getBValue()" />

Upvotes: 0

Related Questions