Files
Kiro/internal/testing/helpers.go

44 lines
1.1 KiB
Go

package testing
import (
"testing"
"github.com/leanovate/gopter"
)
// PropertyTestConfig holds configuration for property-based tests
type PropertyTestConfig struct {
MinSuccessfulTests int
MaxSize int
Workers int
}
// DefaultPropertyTestConfig returns default configuration for property tests
func DefaultPropertyTestConfig() *PropertyTestConfig {
return &PropertyTestConfig{
MinSuccessfulTests: 100,
MaxSize: 100,
Workers: 4,
}
}
// RunPropertyTest runs a property-based test with the given configuration
func RunPropertyTest(t *testing.T, config *PropertyTestConfig, testFunc func(*gopter.Properties)) {
if config == nil {
config = DefaultPropertyTestConfig()
}
parameters := gopter.DefaultTestParameters()
parameters.MinSuccessfulTests = config.MinSuccessfulTests
parameters.MaxSize = config.MaxSize
parameters.Workers = config.Workers
properties := gopter.NewProperties(parameters)
// Call the test function to add properties
testFunc(properties)
// Run the tests
properties.TestingRun(t)
}