-
Notifications
You must be signed in to change notification settings - Fork 2
One tool to generate all test cases #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces TestGen, an automated test generation tool that consolidates and standardizes test creation across ValidGen's codebase. The tool generates unit tests, end-to-end tests, and benchmark tests for all validation/type combinations, reducing manual effort and improving maintainability. A key refactoring accompanies this change: renaming genValidations to GenValidations for export consistency, enabling TestGen to leverage internal code generation logic.
Key Changes:
- Added TestGen tool with comprehensive test generation capabilities for all validation/type combinations
- Exported
genValidationsasGenValidationsto enable cross-package usage by TestGen - Updated build process to integrate automated test generation via new
make testgentarget
Reviewed Changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
testgen/README.md |
Documentation explaining TestGen's purpose, architecture, and usage |
testgen/generate_tests.go |
Main entry point orchestrating test generation workflows |
testgen/validations.go |
Central configuration defining all validation rules, types, and test cases |
testgen/generate_validation_types_tests.go |
Generator for end-to-end validation type tests |
testgen/generate_validation_code_tests.go |
Generator for unit tests of BuildValidationCode function |
testgen/*.tpl |
Templates for generating test files with different configurations |
internal/codegenerator/codegen.go |
Renamed genValidations to GenValidations for export |
internal/codegenerator/build_validator.go |
Updated method receivers and references to GenValidations |
internal/codegenerator/*_test.go |
Updated test files to use GenValidations type |
Makefile |
Added testgen target and updated test generation workflow |
tests/endtoend/generated_*.go |
Updated header comments to reference TestGen |
| generateValidationTypesTests() | ||
| generateValidationCodeTests() |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions generateValidationTypesTests() and generateValidationCodeTests() are called but not defined in this file. These should be generateValidationTypesEndToEndTests() and generateValidationCodeUnitTests() respectively, based on the actual function names in the other files.
| generateValidationTypesTests() | |
| generateValidationCodeTests() | |
| generateValidationTypesEndToEndTests() | |
| generateValidationCodeUnitTests() |
This PR introduces a new automated test generation tool called TestGen and refactors the code generator validation logic to improve maintainability and consistency. The main changes are the addition of the TestGen tool and templates for generating unit tests, the standardization of the
GenValidationstype across the codebase, and updates to the build process to support automated test generation.With these generated tests, some duplicated tests will be removed in another PR.
Test Generation Automation
testgentool, including a comprehensive README (testgen/README.md) describing its purpose, the types of tests it generates, and usage instructions. TestGen automates the creation of unit, end-to-end, and benchmark tests for all validation/type combinations, reducing manual effort and errors.BuildValidationCodefunction, includingtestgen/build_validation_code_test.tpl,testgen/generate_validation_code_tests.go, and updates totestgen/generate_tests.go. These generate exhaustive tests for all supported types and validations, both with and without pointers. [1] [2] [3]Codebase Refactoring and Standardization
genValidationstoGenValidationsand updating all references and method receivers accordingly ininternal/codegenerator/codegen.go,internal/codegenerator/build_validator.go, and related test files. This standardizes the naming and improves code clarity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Build and Workflow Improvements
Makefileto add new targets for running TestGen (testgen), setup, and linting, and revised the test generation step to use the new tool and workflow. This enables easy regeneration of tests and integration into CI/CD pipelines. [1] [2]Minor Cleanups
These changes collectively make the codebase more robust and easier to maintain by automating test generation, standardizing validation logic, and improving the build workflow.