Skip to content

DataGenerator

DataGenerator Class Documentation

Overview:

The DataGenerator class serves as a pivotal component in the test generation framework. Its primary function is to produce test data based on a provided library of test cases and specific configurations. By doing so, it ensures that the generated tests adhere to the given criteria, such as possible fields, modes, and types of cases.

Initialization:

The DataGenerator class can be initialized in various ways, depending on the requirements and the level of specificity needed.

Basic Initialization:

The simplest way to initialize the DataGenerator class is by providing just the test library:

generator = DataGenerator(library=your_test_library)

Full Initialization:

For a more detailed configuration, you can provide additional parameters:

generator = DataGenerator(
    library=your_test_library,
    banned_fields=["field1", "field2"],
    possible_fields=["field3", "field4"],
    possible_modes={"mode1": "value1", "mode2": "value2"},
    type_of_cases=["type1", "type2"],
    types_for_generation=["type3", "type4"],
    amount=10
)

Simplified Initialization:

In cases where you only want to specify the types of cases and types for generation as strings:

generator = DataGenerator(
    library=your_test_library,
    type_of_cases="type1",
    types_for_generation="type3"
)

Usage Examples:

Running the DataGenerator:

To execute the test generation process, use the run method:

generator.run()

Retrieving a Single Test Case:

If you wish to obtain a specific test case, you can use the appropriate method:

# This method needs to be verified in the code for its exact name and usage
single_test_case = generator.get_single_test_case(case_name="desired_case_name")

Accessing Generated Combinations:

Post generation, you can access the combinations created:

combinations = generator.combinations
for combination_name, combination_instance in combinations.items():
    # Process each combination as needed

Result Conclusion:

Upon completion of the test generation process, the results can be accessed and processed as required. The combinations attribute of the DataGenerator class holds the generated test data, with each combination being an instance of the Combination class. This allows for further manipulation, analysis, or export of the test data as needed.

Note: Always refer to the actual code implementation for any updates or changes to the methods and their usages.