Documentation
¶
Overview ¶
Package functional_test_generator provides spec-driven functional test generation for ZAP.
Index ¶
- func ExportScenarios(falconDir string, scenarios []shared.TestScenario) (string, error)
- type BoundaryStrategy
- type ExportTemplate
- type FunctionalTestGeneratorTool
- type GenerateParams
- type GenerateResult
- type HappyPathStrategy
- type NegativeStrategy
- type ScenarioTemplate
- type Strategy
- type StrategyEngine
- type TestGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportScenarios ¶
func ExportScenarios(falconDir string, scenarios []shared.TestScenario) (string, error)
ExportScenarios exports test scenarios to a Markdown report.
Types ¶
type BoundaryStrategy ¶
type BoundaryStrategy struct{}
BoundaryStrategy generates test cases with boundary values.
func (*BoundaryStrategy) Generate ¶
func (s *BoundaryStrategy) Generate(endpointKey string, analysis shared.EndpointAnalysis, baseURL string) []shared.TestScenario
Generate creates boundary test scenarios.
func (*BoundaryStrategy) Name ¶
func (s *BoundaryStrategy) Name() string
type ExportTemplate ¶
type ExportTemplate struct {
Language string // go, javascript, python, etc.
Format string // framework-specific (e.g., jest, pytest, etc.)
}
ExportTemplate generates exportable test code templates. This is a placeholder for future implementation where we can generate actual test code files (e.g., Go test files, Jest tests, pytest, etc.)
func (*ExportTemplate) GenerateTestFile ¶
func (t *ExportTemplate) GenerateTestFile(scenarios []shared.TestScenario, outputPath string) error
GenerateTestFile creates executable test code from scenarios. Future implementation for Sprint 5.4
type FunctionalTestGeneratorTool ¶
type FunctionalTestGeneratorTool struct {
// contains filtered or unexported fields
}
FunctionalTestGeneratorTool generates comprehensive functional tests from the API Knowledge Graph using various testing strategies.
func NewFunctionalTestGeneratorTool ¶
func NewFunctionalTestGeneratorTool(falconDir string, executor *shared.TestExecutor) *FunctionalTestGeneratorTool
NewFunctionalTestGeneratorTool creates a new functional test generator tool.
func (*FunctionalTestGeneratorTool) Description ¶
func (t *FunctionalTestGeneratorTool) Description() string
Description returns the tool description.
func (*FunctionalTestGeneratorTool) Execute ¶
func (t *FunctionalTestGeneratorTool) Execute(args string) (string, error)
Execute generates functional tests from the Knowledge Graph.
func (*FunctionalTestGeneratorTool) Name ¶
func (t *FunctionalTestGeneratorTool) Name() string
Name returns the tool name.
func (*FunctionalTestGeneratorTool) Parameters ¶
func (t *FunctionalTestGeneratorTool) Parameters() string
Parameters returns the tool parameter description.
type GenerateParams ¶
type GenerateParams struct {
BaseURL string `json:"base_url"` // Base URL for API (e.g., http://localhost:3000)
Strategies []string `json:"strategies,omitempty"` // List of strategies (happy, negative, boundary). Empty = all
Endpoints []string `json:"endpoints,omitempty"` // Specific endpoints to test. Empty = all endpoints
Execute bool `json:"execute"` // Whether to execute tests immediately
Export bool `json:"export,omitempty"` // Whether to export test scenarios to file
}
GenerateParams defines the parameters for test generation.
type GenerateResult ¶
type GenerateResult struct {
TotalScenarios int `json:"total_scenarios"`
GeneratedBy map[string]int `json:"generated_by_strategy"` // strategy -> count
Results []shared.TestResult `json:"results,omitempty"` // Only if Execute=true
ExportPath string `json:"export_path,omitempty"` // Only if Export=true
Summary string `json:"summary"`
}
GenerateResult represents the output of test generation.
type HappyPathStrategy ¶
type HappyPathStrategy struct{}
HappyPathStrategy generates valid test cases with correct data.
func (*HappyPathStrategy) Generate ¶
func (s *HappyPathStrategy) Generate(endpointKey string, analysis shared.EndpointAnalysis, baseURL string) []shared.TestScenario
Generate creates happy path scenarios with valid data for every endpoint.
func (*HappyPathStrategy) Name ¶
func (s *HappyPathStrategy) Name() string
type NegativeStrategy ¶
type NegativeStrategy struct{}
NegativeStrategy generates invalid test cases with missing/wrong data.
func (*NegativeStrategy) Generate ¶
func (s *NegativeStrategy) Generate(endpointKey string, analysis shared.EndpointAnalysis, baseURL string) []shared.TestScenario
Generate creates negative test scenarios with invalid data.
func (*NegativeStrategy) Name ¶
func (s *NegativeStrategy) Name() string
type ScenarioTemplate ¶
type ScenarioTemplate struct {
Name string
Description string
Method string
URL string
Headers map[string]string
Body string
Assertions []string
}
ScenarioTemplate represents a template for a test scenario.
func (*ScenarioTemplate) ToGoTest ¶
func (st *ScenarioTemplate) ToGoTest() string
ToGoTest generates Go test code (example for future implementation).
type Strategy ¶
type Strategy interface {
// Generate creates test scenarios for a given endpoint.
Generate(endpointKey string, analysis shared.EndpointAnalysis, baseURL string) []shared.TestScenario
Name() string
}
Strategy defines the interface for test generation strategies.
type StrategyEngine ¶
type StrategyEngine struct {
// contains filtered or unexported fields
}
StrategyEngine is responsible for generating test scenarios based on different strategies.
func NewStrategyEngine ¶
func NewStrategyEngine() *StrategyEngine
NewStrategyEngine creates a new strategy engine with all available strategies.
func (*StrategyEngine) Generate ¶
func (e *StrategyEngine) Generate( endpointKey string, analysis shared.EndpointAnalysis, baseURL string, strategyName string, ) []shared.TestScenario
Generate creates test scenarios using the specified strategy.
type TestGenerator ¶
type TestGenerator struct {
// contains filtered or unexported fields
}
TestGenerator executes generated test scenarios using the shared TestExecutor.
func NewTestGenerator ¶
func NewTestGenerator(executor *shared.TestExecutor) *TestGenerator
NewTestGenerator creates a new test generator.
func (*TestGenerator) ExecuteScenarios ¶
func (g *TestGenerator) ExecuteScenarios(scenarios []shared.TestScenario) []shared.TestResult
ExecuteScenarios runs all test scenarios sequentially and returns the results. Scenarios must have fully qualified URLs (base_url already prepended).