App-Test-Generator
view release on metacpan or search on metacpan
doc/getting-started-blog.md view on Meta::CPAN
---
module: Math::Utils
function: normalize
input:
value:
type: number
position: 0
min:
type: number
position: 1
max:
type: number
position: 2
output:
type: number
min: 0
max: 1
transforms:
min_value_returns_zero:
input:
value: { type: number, value: 0 }
min: { type: number, value: 0 }
max: { type: number, value: 100 }
output:
type: number
value: 0
max_value_returns_one:
input:
value: { type: number, value: 100 }
min: { type: number, value: 0 }
max: { type: number, value: 100 }
output:
type: number
value: 1
midpoint_returns_half:
input:
value: { type: number, value: 50 }
min: { type: number, value: 0 }
max: { type: number, value: 100 }
output:
type: number
value: 0.5
inverted_range_dies:
input:
value: { type: number, value: 50 }
min: { type: number, value: 100 }
max: { type: number, value: 0 }
output:
_STATUS: DIES
iterations: 50
seed: 42
```
This generates tests that verify:
1. The math is correct (transforms)
2. Boundary conditions work (min=0 returns 0, max=100 returns 1)
3. Invalid inputs are rejected (inverted range dies)
4. Random inputs within range work correctly
## The Five-Minute Quick Start
### 1. Install the module
```bash
cpanm App::Test::Generator
```
### 2. Create a configuration file
`t/conf/my_function.yml`:
```yaml
---
module: My::Module
function: my_function
input:
name:
type: string
min: 1
max: 100
age:
type: integer
min: 0
max: 150
optional: true
output:
type: string
seed: 12345
iterations: 50
```
### 3. Generate and run tests
```bash
# Generate the test file
fuzz-harness-generator t/conf/my_function.yml > t/my_function_fuzz.t
# Run it
prove -v t/my_function_fuzz.t
```
### 4. Add to your CI/CD
The best part? Add this to GitHub Actions and it runs automatically:
`.github/workflows/fuzz.yml`:
```yaml
name: Fuzz Testing
on:
( run in 0.797 second using v1.01-cache-2.11-cpan-e1769b4cff6 )