-
Notifications
You must be signed in to change notification settings - Fork 34
Test data generators
Test data generators allow to customize the data values used for each parameter. You can create new test data generators following the steps described below.
Every new data generator must be implement the ITestDataGenerator
interface. You need to implement—at least—two methods:
-
Object nextValue()
. The method must generate a new value and return it. -
String nextValueAsString()
. Same as the previous one, but it returns the value as string.
You can use the generation strategy you prefer to implement your new generator. Place it within the package es.us.isa.restest.inputs
. The default generators are classified by their generation strategy, so we recommend to also classify your generator.
Once you have implemented your new generator, you must modify the TestDataGeneratorFactory
class to add support for the generator. You need to add a new case to the switch
statement of the createTestDataGenerator
method. This method returns a ITestDataGenerator
, so you have to create an instance of your generator inside the case
statement. We recommend to create a new private static
method with the name create<NameOfTheGeneratorClass>
where you instantiate the generator with its parameters. Remember: the String
you add as a new case is the unique String
that identifies your new generator in a test configuration file.