smartcat-labs / ranger

Ranger is contextual data generator used to make sensible data for integration tests or to play with it in the database
https://www.smartcat.io/products/ranger-contextual-data-and-load-generator
Apache License 2.0
59 stars 11 forks source link

Clone value #172

Open vajda opened 7 years ago

vajda commented 7 years ago

Sometimes, it is handy to define and reuse same value within different fields. Using references would end up in having same value generated:

  genre: random(['action', 'horror', 'thriller', 'drama', 'comedy', 'sci-fi', 'fantasy'])
  movie1:
    title: random(...)
    genre: $genre
  movie2:
    title: random(...)
    genre: $genre

This will work, however, both movies will always end up with same genre, but it should be possible for them to have different genres. In order to make this possible, genre should be reused in a way that will create different instances.

Proposed syntax for clone value is:

  genre: random(['action', 'horror', 'thriller', 'drama', 'comedy', 'sci-fi', 'fantasy'])
  movie1:
    title: random(...)
    genre: $$genre
  movie2:
    title: random(...)
    genre: $$genre

This feature should be available within Java API as well. possibly with clone method on generator.