How to reuse a String in another Step of my test?

Asked

Viewed 101 times

0

I have a question (maybe simple for most) and I needed your help...

I am programming an End-to-End Flow of Apis using Java, Restassured and Cucumber (to define my Steps).

In my first API a return proposal number is generated that is used in the body of the other Apis.

How could I capture this String in a Step of my Flow, and reuse it in the other Steps? Someone could help me?

I am grateful for the help from now personal! D

1 answer

0

Caique Pena,

Try the following:

1- Create a global variable;

2- populate the variable with the value you want;

3- reuse in another method;

public class Steps(){
    int idade;

    public void pegaIdade(){
         idade = 10;
    }

    public void reutilizaIdade(){
         int calculaSomaDeIdade = idade + 15;
    }
}

Abç.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.