Description
The EdgeCaseGen Generator generates edge case data useful for negative testing and testing edge cases. An edge case is a rare or unexpected scenario outside the typical usage pattern. They can reveal any vulnerabilities or other unexpected behaviors.
Edge cases can result from unexpected user behaviors, diverse user environments, product complexity, external factors, etc. Examples include the following:
- Rounding Issues for Currency Conversion
- Mismatched Time Zones
- Special Characters in Passwords
- Names Longer than Character Limit
- Names with Invalid Characters
- Uncommon File Format
- Validate Users Age for a Platform
Note: This Generator can be used to define an edge case for an Attribute. You can use G-Cases (Test Data Cases) to set up negative test cases. To learn more, click here.
In This Article
- Generator Parameters
- Example 1 - Create a Negative User Age Every 5 Records
- Example 2 - Create a First Name Longer than 10 Characters 25% of the Time
- Example 3 - Create a number between 1000-100,000 when condition is true; otherwise, create a number less than 1000
Generator Parameters
The following parameters may be configured for the EdgeCaseGen Generator. Items with an asterisk* are required.
- source* - References a value or Attribute to be returned when the edgeCase condition is false.
- edgeCase* - References a value or Attribute to be returned when the edge case condition is true.
- condition - Reference an Attribute whose Generator will only return a Boolean true or false value. The edgeCase value is return when True, and the source value is returned when False.
- cycle - Defines the number of cycles the source value is returned before the edgeCase value is returned.
- percentage - Defines the percentage of time the edgeCase value is returned as opposed to the source value being returned.
- seed - Sets the seed on the internal random generator that is used when the edge case is being determined by percentage.
Example 1 - Create a Negative User Age Every 5 Records
Users are required to input their age, which is valid between 1 and 120 years. A tester wants to ensure that the system handles negative ages correctly. To do so, they must ensure a negative age is generated every five records.
This example uses three linked generators:
The expected output is shown below. The value for the 'case' generator will be what is generated as the output:
RandomGen (age)
Generates an age between 1 and 120 to represent the typical age range for users.
RangeGen (negative)
Generates a negative age range starting at -100 and counting down to -1.
EdgeCaseGen (case)
The attribute will generate a random value within the typical age range (1 to 120). A negative value will be generated for every five records to test the edge case.
- source - references RandomGen (age) for normal age range.
- edgeCase - references RangeGen (negative) to generate a negative age value.
- cycle - edgeCase will be generated every five cycles (or every five records).
Example 2 - Create a First Name Longer than 10 Characters 25% of the Time
In this example, a tester wants to ensure that first names longer than 10 characters are handled correctly. They want to generate test data containing first names within the set limit (10 or under) and create first names larger than the limit (11 or up). The value surpassing the character limit should be chosen over the one within the set limit 25% of the time.
The sample data below contains 5 records with a first name longer than 10 characters.
This example uses three generators:
- ListGen (gen1) - Used instead of NameGen to ensure the names are 10 characters or less.
- ListGen (gen2) - Contains a list of first names that are 11 characters or longer.
- EdgeCaseGen (gen3) - Chooses a name longer than 10 characters 25% of the time over the other value.
ListGen (gen1)
Generates first names 10 characters or less.
ListGen (gen2)
Generates first names longer than 10 characters.
EdgeCaseGen (gen3)
It generates a name with 10 or fewer characters. The longer first name is included in the generated test data 25% of the time.
- source - references ListGen (gen1) to generate names within the acceptable 10 characters or less range.
- edgeCase - references ListGen (gen2) to generate names out of the acceptable range.
- percentage - 25
Example 3 - Create a number between 1000-100,000 when condition is true; otherwise, create a number less than 1000
This example uses four total linked Generators. These three additional Generators are referenced by EdgeCaseGen Generator Parameters:
- RandomGen
- RandomStringGen
- RandomTrueFalseGen
The following are referenced in the EdgeCaseGen Generator configuration:
- source Parameter - References RandomGen (gen1)
- edgeCase Parameter - References RandomStringGen (gen2)
- condition Parameter - References RandomTrueFalseGen (gen3)
RandomGen Generator Configuration (source Parameter Reference):
RandomStringGen Generator Configuration (edgeCase Parameter Reference):
RandomTrueFalseGen Generator Configuration (condition Parameter Reference):
Sample Output
gen4 = Result.
if condition is TRUE = result should be 1,000-100,000.
if condition is FALSE = result should be less than 1,000.