ZZZ
ZZZ

Reputation: 945

How to capture multiple line text in cucumber in Java

I have a Java cucumber test which has the following test case:

.....
And the returned information should be
  """
  This is the first line of my text
  This is the second line of my text
  This is the third line of my text
  """

The step def I wrote is:

@Then("^the returned information should be (.*)$")

This does not work and the multiple line text is not captured. How can I write a working step definition for this?

Upvotes: 3

Views: 3908

Answers (1)

Grasshopper
Grasshopper

Reputation: 9058

Just use this - @Then("^the returned information should be$"). Add a String parameter to the method. The multi line text will be automatically injected into the parameter.

@Then("^the returned information should be$")
public void blahblah(String multi) {}

Upvotes: 5

Related Questions