Как передать многострочную строку в качестве входного параметра для истории jbehave?

У меня есть история jbehave, для которой я передаю строку в качестве данных в параметр.

Пример:

|line|
|hi.how ade you|

Выдает ошибку как

expected hi.how are you

But is : 
hi
how are you

Итак, как я могу справиться с этим вводом в данные... Потому что, если я даю \n, он рассматривает его как часть данных


person Akshay Sarode    schedule 21.11.2016    source источник
comment
Можете ли вы предоставить код, что вы тестировали до сих пор?   -  person Hida    schedule 21.11.2016
comment
Если бы вы получили параметр и добавили в определение строку, которая заменяет все совпадения для \n фактической новой строкой, разве это не решило бы вашу проблему? Вы пытаетесь сделать многострочный текст внутри таблицы, и это не будет работать с большинством тестов на основе корнишонов.   -  person KyleFairns    schedule 21.02.2017


Ответы (1)


История:

Narrative:

As a tester
I want to use a string that spans multiple lines as a parameter
So that I can test scenarios using multiline strings

Scenario: User enters a string that spans multiple lines

When the user enters a string: This
is
a very
long
string

that
spans
multiple
lines

and even
has

some empty
lines


Then I can see this string in the console

Реализация шагов:

public class MySteps {

    private String myString;

    @When("the user enters a string: $string")
    public void userEntersString(String string){
        myString = string;
    }

    @Then("I can see this string in the console")
    public void printTheStringToTheConsole(){
        System.out.println("====== the string starts here =======");
        System.out.println(myString);
        System.out.println("====== the string endss here =======");
    }
}

Результат:

Running story org/buba/jbsimple/stories/my.story

(org/buba/jbsimple/stories/my.story)
Narrative:
As a tester
I want to use a string that spans multiple lines as a parameter
So that I can test scenarios using multiline strings
Scenario: User enters a string that spans multiple lines
When the user enters a string: This
is
a very
long
string

that
spans
multiple
lines

and even
has

some empty
lines
====== the string starts here =======
This
is
a very
long
string

that
spans
multiple
lines

and even
has

some empty
lines
====== the string endss here =======
Then I can see this string in the console



(AfterStories)
person krokodilko    schedule 21.11.2016
comment
Знаете ли вы, как запретить JBehave обрезать строки многострочного параметра? - person Alissa; 13.11.2017
comment
@Alissa, пожалуйста, опубликуйте это как отдельный вопрос, а не комментарий. - person krokodilko; 13.11.2017
comment
Извините, я думал, что здесь все будет в порядке. Опубликовано отдельно: stackoverflow .com/questions/47269885/ - person Alissa; 13.11.2017