mercredi 19 juillet 2017

JBehave and java varargs - how to pass parameters to varargs method?

I have a problem with connecting my method with JBehave framework. Please help me out. Namely, I have JBehave scenario like this:

Scenario: test1
Given all the data with attr1, attr2

Now in steps class I have a method with varargs because dependently on the situations i will use one or many parameters

@Given ("all the data from $attribute1, $attribute2")
    public void testinggg(String... attributes){

    int a = attributes.length;
    for(int i=0;i<a;i++){
        System.out.println(attributes[i]);
    }
    }

Unfortunately I get an error:

Given all the data with attr1, attr2 (FAILED)
(org.jbehave.core.steps.ParameterConverters$ParameterConvertionFailed: No parameter converter for class [Ljava.lang.String;)

Is there workaround for this? How can I pass my parameters to my testinggg(String... attributes) method?

Please, help!

Aucun commentaire:

Enregistrer un commentaire