2

I get a NullPointerException for instance variables that are instantiated in a method with a @Given annotation as shown in the code below for "test":

import com.qmetry.qaf.automation.step.QAFTestStepProvider;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

@QAFTestStepProvider
public class Steps
{
    String test;

    @Given("^Step 1$")
    public void step1()
    {
        test = "test_string";
    }

    @Then("^Step 2$")
    public void step2()
    {
        String[] list = test.split("_");
    }
}

I've seen various examples(second to last code example) and resources(first paragraph of this answer) that say this should be fine, as DI would only be necessary when attempting to share states between Step Definition Java classes, not within a class itself.

Is there something I am missing or is there a way to make this work?

user861594
  • 4,526
  • 3
  • 23
  • 39
jr09
  • 23
  • 2

1 Answers1

0

As per qaf-release-notes-2.1.9 you need to set step.provider.sharedinstance to true (default value is false). In application properties you can specify

step.provider.sharedinstance=true

user861594
  • 4,526
  • 3
  • 23
  • 39