Using variables in Concordion markdown -


when writing test specification in concordion, want include output of call in script. example, want test rest service posting new object , verifying returned object includes own uri string. in these circumstances, think it's right format of uri string included in test script rather buried within fixture.

assuming object named newproduct has been created somehow, write this:

when [post new product](- "#response=post(#newproduct)")<br/> [product record](- "#product=getcontent(#response)") returned<br/> , [id](- "c:set=#productid=getid(#product)") [ ](- "c:echo=#productid)")<br/> , hal reference matches [products/#productid](- "?=gethalref(#product)") 

unfortunately variable productid in last line not resolved. approach recommend?

i'd recommend stating static format of uri string in specification rather actual values (which dynamic , lead different spec each time).

the fixture can compare expected , actual formats. technique described in context of date conversion in instrumentation documentation.

using technique, markdown written as:

when [post new product](- "#response=post(#newproduct)")<br/> [product record](- "#product=getcontent(#response)") returned<br/> hal reference matching [products/#productid](- "?=checkhalref(#product, #text)") ( _[#productid](- "#productid=getid(#product)") [ ](- "c:echo=#productid")_ )

with checkhalref method:

public string checkhalref(string product, string expected) { string halref = gethalref(product); string expectedhalref = expected.replace("#productid", getid(product)); if (halref.equals(expectedhalref)) { return expected; } return halref; }

on success, output documentation show:

successful example

and on failure:

enter image description here


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -