What prompts would one give an LLM if one was seeking to generate a test dataset based on a JSON Schema. I'm particularly interested what sort of additional documentation would make the test dataset most effective.. Use Case documents explaining the business rules and relationships between things in the domain model?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Generating a test dataset based on a JSON Schema using a Large Language Model (LLM) can be highly effective if you provide the right prompts and additional documentation. Below are detailed prompts and types of additional documentation that will help the LLM generate a comprehensive and accurate test dataset.
Prompts for the LLM
Basic Schema Interpretation:
code
Given the following JSON Schema, generate a valid JSON instance that adheres to the schema:
{
"JSON_SCHEMA_HERE"
}
Diverse Data Generation:
code
Using the provided JSON Schema, generate multiple (e.g., 10) diverse JSON instances to cover various valid scenarios:
{
"JSON_SCHEMA_HERE"
}
Boundary Value Analysis:
code
Generate JSON instances that test boundary values for each property in the following JSON Schema:
{
"JSON_SCHEMA_HERE"
}
Please include instances that use minimum, maximum, and just outside these bounds where applicable.
Required Fields Validation:
code
Create JSON instances to validate that all required fields in the following JSON Schema are present and correctly formatted. Also, generate instances that intentionally omit required fields to test error handling:
{
"JSON_SCHEMA_HERE"
}
Enum and Pattern Validation:
code
Generate JSON instances that test all enum values and regex patterns defined in the following JSON Schema:
{
"JSON_SCHEMA_HERE"
}
Also, create instances with values that do not match enums or patterns to test validation failures.
Nested Objects and Arrays:
code
Generate complex JSON instances that include nested objects and arrays as defined in the following JSON Schema. Ensure that nested structures adhere to their respective schemas:
{
"JSON_SCHEMA_HERE"
}
Reference ($ref) Resolution:
code
Generate JSON instances for the following JSON Schema, ensuring that all $ref references are correctly resolved and that the generated data adheres to the referenced schemas:
{
"JSON_SCHEMA_HERE"
}
Additional Documentation for Effective Test Datasets
To make the test dataset most effective, the following types of additional documentation should be provided:
Use Case Documents:
Description: Documents that explain the various use cases for the JSON data. These should detail how the JSON data will be used in the application, including different scenarios and edge cases.
Prompt Example:
code
Considering the use cases documented below, generate JSON instances that represent typical and edge-case scenarios for each use case:
Use Case 1: User Profile Creation
- Typical Scenario: A user creates a profile with all required information.
- Edge Case: A user attempts to create a profile with minimal required information.
Use Case 2: Order Processing
- Typical Scenario: An order is placed with multiple items.
- Edge Case: An order is placed with only one item and uses a promotional code.
JSON Schema:
{
"JSON_SCHEMA_HERE"
}
Business Rules Documentation:
Description: Documentation that outlines the business rules governing the data. This includes constraints, relationships between entities, and any business logic that affects the data.
Prompt Example:
code
Generate JSON instances that adhere to the following business rules while conforming to the provided JSON Schema:
Business Rules:
1. A user must be at least 18 years old to create an account.
2. An order must have at least one item.
3. Discount codes can only be applied to orders over $100.
JSON Schema:
{
"JSON_SCHEMA_HERE"
}
Domain Model Relationships:
Description: Documentation that explains the relationships between different entities in the domain model. This helps ensure that the generated data maintains referential integrity and accurately represents real-world relationships.
Prompt Example
code
By providing these prompts and additional documentation, you will guide the LLM to generate a comprehensive and effective test dataset that thoroughly validates the JSON Schema and covers a wide range of scenarios, including edge cases and error conditions.
Generate JSON instances that accurately represent the relationships between entities as described in the domain model below, while adhering to the provided JSON Schema:
Domain Model Relationships:
- A `User` can have multiple `Orders`.
- An `Order` can contain multiple `Items`.
- Each `Item` must reference a valid `Product`.
JSON Schema:
{
"JSON_SCHEMA_HERE"
}
Example Data:
Description: Real or hypothetical examples of valid and invalid JSON instances. These examples serve as a reference for the LLM to understand the expected output better.
Prompt Example:
code
Generate additional JSON instances similar to the following examples, ensuring they conform to the provided JSON Schema:
Valid Example:
{
"example_valid_json_here"
}
Invalid Example (for negative testing):
{
"example_invalid_json_here"
}
JSON Schema:
{
"JSON_SCHEMA_HERE"
}
Error Cases and Negative Testing:
Description: Documentation that lists common error cases and scenarios for negative testing. This ensures that the test dataset includes instances that should fail validation, helping to test the robustness of the validation logic.
Prompt Example:
code
Generate JSON instances that represent the following error cases to test negative scenarios against the provided JSON Schema:
Error Cases:
1. Missing required field `username`.
2. `age` field is less than the minimum allowed value.
3. `email` field does not match the required pattern.
JSON Schema:
{
"JSON_SCHEMA_HERE"
}