java - Good practice to pass variables between cucumber-jvm steps -


Now I am doing something like an example to pass the variable between the steps:

  Feature: demo scenario: user user creation form management create the user has created the Java class with the "Test" make known the user successfully  

Speed ​​definitions:

  public class CreateUserSteps {Private string user name; @ ( "^ User Construction Forms Management $") public void User_creation_form_management () thrrowable throws {// ...} @ ( "^ Create a user with the name" ([^ \ "] *) \" $ ") public void Create_user_with_name (string username) Throhebl {// ... this.userName = userName;} ^ @ again ( "the user has been successfully created $") public void User_is_created_successfully () is equal to the throws // name thrrowable .User name}  

My question is whether to share information between steps Is this a good practice? Or would better define this feature:

  Then the user has been successfully created with the name "test"  

I used cucumber I am new with -jevim, so I'm sorry that it's a treacherous question.

thanks for any would appreciate the help.

To share the similarities between the steps you use. Not so in Java, it is obvious as Ruby.

Cancer creator.

The purpose of "world" is two times:

1) Separate the state between the circumstances.

2) Share data between step scenarios and hooks in a scenario.

How it is implemented is language specific For example, in Ruby, the underlying itself variables inside a defined definition indicates the global object of the current scenario. Is an example of an object, but if you use a world hook, then it can be anything from you.

In Java, you have several (possibly linked) world objects.

The world is equal to all objects with hook or stepped annotation . In other words, with any of the methods commented on @ East, @Efter, Given and so on, any class will be instant once for every scenario.

This achieves the first goal You have two approaches to achieving the other goal:

a) Use a single class for all your steps definitions and hooks < / P>

b) Use several sections divided responsibly [1] and use dependency injection [2] to connect them to each other.

Option a) breaks quickly because your stage definition code gets messy, this is why people use B.).

[1]

[2] Pico Contanetr, Spring, guides, weld, open Ijebi, needle

are available dependency injection module:

  • cucumber-Pikokonteniyr
  • cucumber-invoice
  • cucumber-Openjb
  • Kkdi- spring
  • Cucumber-weld
  • Cucumber-needle

Original post here.

Hope it helps.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -