Faker DSL¶
Faker comes with a DSL to create Faker
and FakerConfig
instances.
If you're using kotlin - chances are, you will want to use a DSL for creating and configuring Faker
instances. An exception to this could be if you want to postpone creating the FakerConfig
instance to a later point, in which case check out the "Non-DSL" way of configuring Faker
s.
❶ Use the faker
dsl function to create an instance of Faker
.
❷ Inside the faker
dsl function use fakerConfig
function to configure this instance of Faker
.
❶ Alternatively create FakerConfig
instance with the top-level fakerConfig
function.
❷ Create the Faker
instance with custom configuration.
❶ Create FakerConfig.Builder
instance and postpone instantiation of FakerConfig
.
❷ Add extra configuration later on.
❸ Build the FakerConfig
when ready.
❹ Create the Faker
instance with custom configuration
Tip
If you're interested in using the DSL from Java, check out the Java Interop - Using Faker DSL for more details.
Also take a look at the Faker Configuration page which also describes how to configure Faker
in a more "traditional-java-way".