Miguel D'Alessio
Miguel D'Alessio

Reputation: 116

It is necessary to include a random number in the step you want or not include it

include a random number in the specific steps you want Example:

Feature: Zonas

@TEST
Scenario Outline: TEST
Given Insert <Descripcion>
And insert <CodigoDeInterfaz>
And Validate Description <Descripcion>
And Validate CodigoDeInterfaz <CodigoDeInterfaz>
Examples:
| Descripcion    | CodigoDeInterfaz      |
| DescTH6456565          | CodDeIntHT45645645   

i need include random number in values

Examples:
| Descripcion    | CodigoDeInterfaz      |
| Desc <RANDOM>  | CodDeIntHT <RANDOM>   | <---- here

so the input parameters all include the random number

  1. SpecFlow 2.3.2
  2. C#
  3. NUnit 3

Upvotes: 1

Views: 1272

Answers (2)

Sam Holder
Sam Holder

Reputation: 32936

The easiest way to do this IMHO is to use a StepArgumentTransformation, something like this:

[Then("And Validate Description (.*)")]
public void ThenValidateDescription(RandomisedValue description)
{}

[StepArgumentTransformation]
public RandomisedValue ToRandomisedValue(string initialInput)
{
    return initialInput + GetRandomData();
}

specflow will call your step argument transformation method with the data in the method, you add your random element and return the class that represents the data that has been randomised. As long as you have a distinct class for each type of randomisation you want then specflow will be able to determine which of the step argument transformations it should call...

Upvotes: 1

Rami A.
Rami A.

Reputation: 10592

You can try to use Specflow.DSL.

Feature: Zonas

@TEST
Scenario Outline: TEST
Given Insert <Descripcion>
And insert <CodigoDeInterfaz>
And Validate Description <ValidateDescripcion>
And Validate CodigoDeInterfaz <ValidateCodigoDeInterfaz>
Examples:
| Name   | Descripcion                     | ValidateDescripcion  | CodigoDeInterfaz                     | ValidateCodigoDeInterfaz |
| Random | [[Descripcion=RegEx([0-9]{7})]] | [[Descripcion]]      | [[CodigoDeInterfaz=RegEx([0-9]{7})]] | [[CodigoDeInterfaz]]     |

Upvotes: 3

Related Questions