Search code examples
bddconcordion

How do you use concordion:run with parameters?


I would like to run a Concordion spec using a parameter. What I'd like to do is execute the spec using concordion:run. A little research pointed me to the existence of a concordion:params attribute, but I cannot find any documentation or examples.

I'm not sure how these two commands fit together; should the params element be nested inside the run element or outside? What is the value to fill in concordion:params="?" Where do I specify the param values themselves--in a concordion:set call?


Solution

  • concordion:params is an attribute to be used on the same element as the concordion:run attribute.

    For example, in MyIndex.html:

    <a concordion:run="concordion" concordion:params="foo=5" href="MySpec.html">My Spec</a>
    

    with the fixture class:

    @RunWith(ConcordionRunner.class)
    @FullOGNL
    public class MyIndex {
        public void setFoo(Integer foo) {
            System.out.println("foo = " + foo);
        }
    }
    

    Note that the @FullOGNL attribute is required to allow the syntax foo=5 in the expression that wouldn't otherwise be allowed.

    NOTE: Tim Wright has pointed out an issue with this approach:

    The issue I see is that the same specification might be run from two different specifications (or run twice from a single specification) with different parameters as well as from jUnit with no parameters. As we only create one HTML file, the behaviour might not be what the user expects. It also means that using concordion:run will create a different specification from running the spec directly as a jUnit test - which is something we've tried hard to avoid.

    The current behaviour (with the concordion run cache) is that the first one to be called will create the HTML file - and the second one will return a run results from the cache thus ignoring the parameter.

    This may mean that we deprecate concordion:params and remove it in 2.0.