Generating Fake Test Data

*Introduced in API Fortress 17.1.0*

Does your API or test require random full names, valid/invalid ids, or various types of input data? Well now you can generate these random data points directly in API Fortress with the Fake Data Generator.

There are a couple of ways you can generate this data:

You can directly reference the method within your variable, API call, or anywhere in the test where you can type in the following syntax: “${F.zipCode()}”

For example:

You can use the “Fake data generation” component to generate this data.

There are a few different ways this component can be used. You can use it to generate a string, array, or an object. See below for examples.

  1. Generate a String

Var – name of variable in which data will be stored (for referencing in the test elsewhere)
Variable mode – String (single piece of data)
String – Here you will put the name of the type of data you want. See the list below for all options. Some examples are firstName, lastName, and emailAddress.
Count – How many examples of this data type would you like to generate.

2. Generate an Array

Var – name of variable in which data will be stored (for referencing in the test elsewhere)
Variable mode – Array (multiple data points)
Array – Here you will put the name of the type of data you want. See the list below for all options. Some examples are firstName, lastName, and emailAddress.
Count – How many arrays of these data types would you like to generate. (Notice that the count field has been left blank, in that case the system will generate 1 iteration of the data)

3. Generate an Object

Var – name of variable in which data will be stored (for referencing in the test elsewhere)
Variable mode – Object (a map of name:data point). This is often used to create JSON objects.
Array – Here you will put the name of the type of data you want. See the list below for all options. Some examples are firstName, lastName, and emailAddress.
Count – How many strings of this data type would you like to generate.

List of Methods

Please note that the method itself is listed below. When using the Fake data component only use the name of the method without the “()”

Addresses and Countries

  • streetName(): provides random street name
  • streetAddressNumber(): provides random address number
  • streetAddress(): provides random street and address number. If secondary specified provides apt number.
  • secondaryAddress(): provides random apt number
  • zipCode(): provides random zip code. If state provided provides proper zip code for the state **(valid only for US states)
  • streetSuffix(): provides random street suffix
  • streetPrefix(): provides random street prefix
  • citySuffix(): provides random city suffix
  • cityPrefix(): provides random city prefix
  • city(): provides random city Name
  • cityName(): provides random city Name
  • state(): provides random state/province
  • buildingNumber(): provides random build number
  • fullAddress(): provides random full address
  • country(): provides random country
  • countryCode(): provides random country code
  • countryCodeSL(): provides random country code in small letters
  • countryCodeSL3d(): provides random country code in small letters on 3 digits
  • capital(): provides random capital city

People and People identity

  • fullName(): provides random full name
  • firstName(): provides random first name
  • lastName(): provides random last name
  • profession(): provides random profession
  • timeZone(): provides random time zone
  • validID(): provides random valid ID
  • invalidID(): provides random invalid ID
  • validSSN(): provides random valid SSN
  • invalidSSN(): provides random invalid SSN
  • phone(): provides random phone number
  • mobile(): provides random mobile number

Internet

  • emailAddress(): provides random email address
    • ***It is to be noted that these email addresses are randomly generated with real domains. Please be careful if you are using this in a test and connecting to a mailer of sorts, there is a chance that some of them could be real email addresses.***
  • domainName(): provides random domain name
  • domainWord(): provides random word
  • domainSuffix(): provides random suffix
  • url(): provides random url
  • password: provides random password
    • Syntax: (<minimumLength,maximumLength,includeUppercase,includeSpecial,includeDigit>)
    • Example: password(5,10,true,false)

Credit Card

  • creditCardNumber(): provides random credit card number
  • creditCardExpiry(): provides random credit card expire date
  • creditCardType(): provides random credit card type

Products

  • productName(): provides random product name
  • material(): provides random material
  • price(): provides random price
  • promotionCode(): provides random promotion code

Companies

  • companyName(): provides random company name
  • suffix(): provides random company suffix
  • industry(): provides random industry

Currency

  • currency(): provides random currency
  • currencyCode(): provides random currency code

Random Numbers

  • integer: provides random integer number
    • Syntax: (<min,max>)
    • Example: integer(2,20)
  • decimal: provides random decimal number
    • Syntax: (<min,max,maxdecimals>)
    • Example: decimal(0,2,2)
  • uuid(): provides random unique identifier

Boolean

  • bool(): provides random boolean value

Collection/single Data

  • collection(<number_of_elements,”method”>):
    • provides a list of elements generated by “method”.
    • The single element is a simple string.
    • The size of the list is equal to the number_of_elements
  • collection(<number of elements,[“method1″,”method2”,…,”methodN2]>):
    • provides a list of elements generated by the list of methods provided.
    • The single element is a list.
    • The size of the list is equal to the number_of_elements
  • collection(<number of elements,[method1: ‘method1′,method2:’method2′,…,methodN:’methodN’>):
    • provides a list of elements generated by the list of methods provided.
    • The single element is a map.
    • The size of the list is equal to the number_of_elements
  • single(<“method”>):
    • provides an element generated by “method”.
    • The element is a simple string.
  • single(<[“method1″,”method2”,…,”methodN2]>):
    • provides an element generated by the list of methods provided.
    • The element is a list.
  • single(<[method1: ‘method1′,method2:’method2′,…,methodN:’methodN’>):
    • provides an element generated by the list of methods provided.
    • The single element is a map