|
| 1 | +# Test Parametrization Implementation Summary |
| 2 | + |
| 3 | +## Overview |
| 4 | +Successfully parametrized all Gradle plugin tests to verify file/directory properties work with both String-based (`.absolutePath`) and File-based (`file()`) formats. |
| 5 | + |
| 6 | +## Changes Implemented |
| 7 | + |
| 8 | +### 1. TestBase.kt |
| 9 | +- Added `PropertyFormat` enum with `STRING` and `FILE` values |
| 10 | +- Added `String.toPropertyReference(format: PropertyFormat)` extension function |
| 11 | +- Added comprehensive KDoc documentation |
| 12 | + |
| 13 | +### 2. GenerateTaskConfigurationCacheTest.kt |
| 14 | +- Updated data providers to include format parameter |
| 15 | +- FILE format only tested with Gradle 8.7 |
| 16 | +- Converted `inputSpecExtensionContents` to function |
| 17 | +- Updated 2 test methods |
| 18 | +- **Test count**: 3 → 5 (+2) |
| 19 | + |
| 20 | +### 3. GenerateTaskUpToDateTest.kt |
| 21 | +- Updated data provider: `[["8.7", "STRING"], ["7.6.4", "STRING"], ["8.7", "FILE"]]` |
| 22 | +- Converted 4 extension content vals to functions |
| 23 | +- Updated 8 test methods |
| 24 | +- **Test count**: 16 → 20 (+4) |
| 25 | + |
| 26 | +### 4. GenerateTaskFromCacheTest.kt |
| 27 | +- Updated data provider with same pattern as UpToDateTest |
| 28 | +- Converted 4 extension content vals to functions |
| 29 | +- Updated 8 test methods |
| 30 | +- **Test count**: 16 → 20 (+4) |
| 31 | + |
| 32 | +### 5. ValidateTaskDslTest.kt |
| 33 | +- Updated data provider: `[[null, "STRING"], ["8.7", "STRING"], ["7.6.4", "STRING"], ["8.7", "FILE"]]` |
| 34 | +- Added `inputSpecProperty()` helper method |
| 35 | +- Updated 8 test methods (kept 1 non-parametrized) |
| 36 | +- **Test count**: 30 → 39 (+9) |
| 37 | + |
| 38 | +### 6. GenerateTaskDslTest.kt |
| 39 | +- Added property format data provider |
| 40 | +- Converted `defaultBuildGradle` to function |
| 41 | +- Parametrized 13 tests (excluded URL-based test) |
| 42 | +- **Test count**: 14 → 27 (+13) |
| 43 | + |
| 44 | +### 7. MetaTaskDslTest.kt |
| 45 | +- Added property format data provider |
| 46 | +- Parametrized `outputFolder` property with special handling for DirectoryProperty |
| 47 | +- **Test count**: 1 → 2 (+1) |
| 48 | + |
| 49 | +### 8. GeneratorsTaskDslTest.kt |
| 50 | +- **No changes** - doesn't use file/directory properties |
| 51 | + |
| 52 | +## Total Impact |
| 53 | +- **Total test count**: 65 → 98 tests (+33 tests, +51% increase) |
| 54 | +- **Strategy**: FILE format tests ONLY with Gradle 8.7 for performance |
| 55 | +- **Consistency**: All properties in single test use same format (no mixing) |
| 56 | + |
| 57 | +## Running the Tests |
| 58 | + |
| 59 | +### Run all tests: |
| 60 | +```cmd |
| 61 | +cd C:\Users\jachymm\IdeaProjects\openapi-generator-forked\modules\openapi-generator-gradle-plugin |
| 62 | +gradlew.bat test |
| 63 | +``` |
| 64 | + |
| 65 | +### Run specific test class: |
| 66 | +```cmd |
| 67 | +gradlew.bat test --tests GenerateTaskConfigurationCacheTest |
| 68 | +gradlew.bat test --tests GenerateTaskUpToDateTest |
| 69 | +gradlew.bat test --tests GenerateTaskFromCacheTest |
| 70 | +gradlew.bat test --tests ValidateTaskDslTest |
| 71 | +gradlew.bat test --tests GenerateTaskDslTest |
| 72 | +gradlew.bat test --tests MetaTaskDslTest |
| 73 | +``` |
| 74 | + |
| 75 | +### Run with more output: |
| 76 | +```cmd |
| 77 | +gradlew.bat test --info |
| 78 | +gradlew.bat test --debug |
| 79 | +``` |
| 80 | + |
| 81 | +### Run and generate HTML report: |
| 82 | +```cmd |
| 83 | +gradlew.bat test |
| 84 | +:: Report will be at: build\reports\tests\test\index.html |
| 85 | +``` |
| 86 | + |
| 87 | +## Properties Parametrized |
| 88 | + |
| 89 | +The following file/directory properties are now tested with both formats: |
| 90 | + |
| 91 | +1. **inputSpec** - Input OpenAPI specification file |
| 92 | +2. **outputDir** - Output directory for generated code |
| 93 | +3. **inputSpecRootDirectory** - Root directory for multiple spec files |
| 94 | +4. **templateDir** - Custom template directory |
| 95 | +5. **configFile** - Configuration file |
| 96 | +6. **ignoreFileOverride** - Override file for .openapi-generator-ignore |
| 97 | +7. **outputFolder** - Output folder for meta task (MetaTask only) |
| 98 | + |
| 99 | +## Test Naming Convention |
| 100 | + |
| 101 | +Tests now include the format in their execution, displayed by TestNG as: |
| 102 | +- `testMethod[8.7, STRING]` |
| 103 | +- `testMethod[8.7, FILE]` |
| 104 | +- `testMethod[7.6.4, STRING]` |
| 105 | + |
| 106 | +## Verification |
| 107 | + |
| 108 | +All modified test files compile without errors. Some type inference warnings exist but are benign and don't affect functionality. |
| 109 | + |
| 110 | +## Next Steps |
| 111 | + |
| 112 | +1. Run the tests using the commands above |
| 113 | +2. Review test results in the HTML report |
| 114 | +3. If any tests fail, check the output for specific error messages |
| 115 | +4. The FILE format tests specifically validate that Gradle properly resolves File objects to absolute paths internally |
| 116 | + |
0 commit comments