Grammar Based Test Data - Instructions
Grammar Based Test Data creates random text from bracketed phrase patterns.
Using The Tool
Enter one or more grammar lines in the text area. Each line can contain bracketed comma-separated choices:
The [quick, careful, curious] tester found a [bug, clue, pattern]
You can also define named phrase lists and insert them into templates with #phrase_name:
phrase_insert: [when, we might choose to, "optional quotes, because i added a comma"]
this is a phrase with a #phrase_insert
Phrase definition lines are not part of the template pool, so the example above only generates from this is a phrase with a #phrase_insert.
Phrase lists can also refer to other phrase lists:
nums: [one, two, three]
phrase: [over, above, #nums]
this is a #phrase
That can generate this is over, this is above, this is one, this is two, or this is three.
Use "" when you want a choice that deliberately generates nothing:
optional_laughter: ["", Bwahaha!, LOL!]
Testing is all about [bugs, feedback, questions] #optional_laughter
Click Generate Grammar to load your definition. Choose how many values to create, choose the output format, optionally enable Clean spacing and punctuation, then click Generate Data.
Output can be generated as:
- a JSON array, for example
["phrase 1","Phrase 2"] - newline-separated text
- CRLF-separated text
- an HTML unordered list, for example
<ul><li>phrase 1</li></ul> - a Markdown list
Use Copy to Clipboard to copy the generated text area content.
Grammar Rules
- one line is selected each time data is generated
- example:
Hello [Alice, Bob]andGoodbye [Alice, Bob]are two possible template lines
- example:
- phrase definition lines use
name: [option 1, option 2]- example:
role: [admin, editor, viewer]
- example:
- phrase definition lines are not generated as templates
- example:
role: [admin, editor]defines data, but onlyUser is #roleis generated
- example:
- phrase definitions can be inserted with
#phrase_name- example:
User is #role
- example:
- phrase definitions can reference other phrase definitions
- example:
phrase: [over, above, #nums]
- example:
- bracketed groups are split on commas
- example:
[small, medium, large]
- example:
- quoted options can contain commas
- example:
["optional quotes, because commas are useful", plain option]
- example:
- one phrase from each bracketed group is selected
- example:
The [quick, careful] tester found a [bug, clue]
- example:
- bracketed groups can be nested inside options
- example:
[bob, and [gain, lose] something]
- example:
- unknown phrase references produce an error
- example:
This uses #missing_phrase
- example:
- recursive phrase references are stopped with an error
- example:
a: [#b]andb: [#a]
- example:
- text outside bracketed groups is preserved
- example:
Order [1001, 1002] is readyalways keepsOrderandis ready
- example:
- lines without bracketed groups can be used as fixed output values
- example:
hello world
- example:
- explicit empty options can be written as
""- example:
optional_laughter: ["", Bwahaha!, LOL!]
- example:
- output can be cleaned to remove extra spaces before punctuation and capitalize the first letter
- example:
testing is fun !becomesTesting is fun!
- example:
- empty input generates an empty output instead of an error
- example: a blank grammar text area generates blank output
Example Definitions
The [small, large, hidden] form accepted [valid, invalid, unexpected] input
User [Alice, Bob, Charlie] has role [admin, editor, viewer]
Order [1001, 1002, 1003] is [pending, shipped, cancelled]
[bob, and [gain, lose] something]
phrase_insert: [when, we might choose to, "optional quotes, because i added a comma"]
this is a phrase with a #phrase_insert
optional_laughter: ["", Bwahaha!, LOL!]
Testing is all about [bugs, feedback, questions] #optional_laughter
nums: [one, two, three]
phrase: [over, above, #nums]
this is a #phrase
The example grammar page includes the Evil Tester Sloganizer grammar as a larger copyable example.
For an exploratory testing exercise with deliberate bugs, use the Grammar Data Gen app.