Repository navigation
v1.2.0
This version introduces the ability to refactor test cases as part of the Analyze command! The only refactoring strategy available in this version is to add t.Run() subtests to table-driven tests that don't have it already, but a framework has been established to allow additional strategies in the future!
What's Changed
✨ New Features
- Implement "subtest" refactoring strategy in
Analyzecommand- Execute all tests before and after refactoring to verify success without modifying behavior
- Output clearly differentiates between errors in the refactor generation and execution phases using various new struct types
- Save refactoring changes on disk for manual analysis using
keep-refactored-filesoption, or revert files to their original state by default - Avoids compilation errors by modifying the scenario runner if needed:
- Replaces some
continuestatements withreturnto indicate that the test should pass without performing more logic - Modifies the scenario runner's "loop key" variable if scenario names are stored as a map key, instead of trying to access a scenario struct field
- Detects the
*testing.Tparameter name dynamically as opposed to hardcoding it
- Replaces some
- Example output: ollama_api_TestMessage_UnmarshalJSON.json
- Clone helper functions internally during refactoring to avoid interference with multiple test cases
- Completely expand package-local helper function calls within test cases
- This opens the door for more detailed analysis when helper functions are used to extract test logic
- Minor scenario field detection improvements
- Prioritize detecting scenario name field from the first
t.Run()argument - Enforce that scenario name field must be a string
- Update scenario runner field to store entire loop statement instead of just the body
- Require scenario runner to be detected directly in the test function to reduce table-driven test false positives
- Prioritize detecting scenario name field from the first
- Remove
timeroption, leaving it enabled permanently
🐛 Bug Fixes
- Fix nil pointer dereference for empty or non-analyzed test cases
- Scenario fields of user-defined type with underlying
stringtype are no longer considered a valid scenario name - Table-driven tests using a map like
map[string]boolnow properly detect the use oft.Run()
🛠️ Internal Improvements
- Completely restructure
testcasepackage structure (see b9fa7c1) - Create
internal/asttoolspackage to hold AST-related util functions
Full Changelog: v1.1.1...v1.2.0