Documentation
¶
Overview ¶
Package core provides the main framework orchestrator and core interfaces
Index ¶
- Constants
- func GetErrorContext(err error) map[string]interface{}
- func GetVersion() string
- func GetVersionString() string
- func IsGowrightError(err error) bool
- func RetryWithBackoff(ctx context.Context, config *RetryConfig, operation RetryableOperation) error
- type APIErrorRecovery
- type APIExpectation
- type APIResponse
- type APIStepAction
- type APIStepValidation
- type APITest
- type APITester
- type AssertionStep
- type BrowserErrorRecovery
- type CleanupConfig
- type CleanupFunc
- type CleanupManager
- func (cm *CleanupManager) ExecuteCleanup() *CleanupMetrics
- func (cm *CleanupManager) RegisterCleanup(name string, fn func() error, priority int)
- func (cm *CleanupManager) RegisterCleanupWithTimeout(name string, fn func() error, priority int, timeout time.Duration)
- func (cm *CleanupManager) Shutdown() *CleanupMetrics
- type CleanupMetrics
- type DatabaseErrorRecovery
- type DatabaseExpectation
- type DatabaseResult
- type DatabaseStepAction
- type DatabaseStepValidation
- type DatabaseTest
- type DatabaseTester
- type EnhancedFunctionTest
- type ErrorRecoveryManager
- type ErrorRecoveryStrategy
- type ErrorType
- type FunctionTest
- type FunctionTestBuilder
- func (tb *FunctionTestBuilder) Build() Test
- func (tb *FunctionTestBuilder) WithRetries(retries int) *FunctionTestBuilder
- func (tb *FunctionTestBuilder) WithSetup(setup func() error) *FunctionTestBuilder
- func (tb *FunctionTestBuilder) WithTeardown(teardown func() error) *FunctionTestBuilder
- func (tb *FunctionTestBuilder) WithTestFunc(testFunc func(*TestContext)) *FunctionTestBuilder
- func (tb *FunctionTestBuilder) WithTimeout(timeout time.Duration) *FunctionTestBuilder
- type Gowright
- func (g *Gowright) Cleanup() error
- func (g *Gowright) Close() error
- func (g *Gowright) ExecuteAPITest(test *APITest) *TestCaseResult
- func (g *Gowright) ExecuteDatabaseTest(test *DatabaseTest) *TestCaseResult
- func (g *Gowright) ExecuteIntegrationTest(test *IntegrationTest) *TestCaseResult
- func (g *Gowright) ExecuteUITest(test *UITest) *TestCaseResult
- func (g *Gowright) GetAPITester() APITester
- func (g *Gowright) GetConfig() *config.Config
- func (g *Gowright) GetDatabaseTester() DatabaseTester
- func (g *Gowright) GetIntegrationTester() IntegrationTester
- func (g *Gowright) GetTestSuite() *TestSuite
- func (g *Gowright) GetUITester() UITester
- func (g *Gowright) Initialize() error
- func (g *Gowright) IsInitialized() bool
- func (g *Gowright) SetAPITester(tester APITester)
- func (g *Gowright) SetDatabaseTester(tester DatabaseTester)
- func (g *Gowright) SetIntegrationTester(tester IntegrationTester)
- func (g *Gowright) SetTestSuite(suite *TestSuite)
- func (g *Gowright) SetUITester(tester UITester)
- type GowrightError
- type GowrightOptions
- type IntegrationStep
- type IntegrationStepAction
- type IntegrationStepType
- type IntegrationStepValidation
- type IntegrationTest
- type IntegrationTester
- type MockAPITester
- func (m *MockAPITester) Cleanup() error
- func (m *MockAPITester) Delete(endpoint string, headers map[string]string) (*APIResponse, error)
- func (m *MockAPITester) ExecuteTest(test *APITest) *TestCaseResult
- func (m *MockAPITester) Get(endpoint string, headers map[string]string) (*APIResponse, error)
- func (m *MockAPITester) GetName() string
- func (m *MockAPITester) Initialize(cfg interface{}) error
- func (m *MockAPITester) Post(endpoint string, body interface{}, headers map[string]string) (*APIResponse, error)
- func (m *MockAPITester) Put(endpoint string, body interface{}, headers map[string]string) (*APIResponse, error)
- func (m *MockAPITester) SetAuth(auth *config.AuthConfig) error
- type MockDatabaseTester
- func (m *MockDatabaseTester) BeginTransaction(connectionName string) (Transaction, error)
- func (m *MockDatabaseTester) Cleanup() error
- func (m *MockDatabaseTester) Connect(connectionName string) error
- func (m *MockDatabaseTester) Execute(connectionName, query string, args ...interface{}) (*DatabaseResult, error)
- func (m *MockDatabaseTester) ExecuteTest(test *DatabaseTest) *TestCaseResult
- func (m *MockDatabaseTester) GetName() string
- func (m *MockDatabaseTester) Initialize(cfg interface{}) error
- func (m *MockDatabaseTester) ValidateData(connectionName, query string, expected interface{}) error
- type MockIntegrationTester
- func (m *MockIntegrationTester) Cleanup() error
- func (m *MockIntegrationTester) ExecuteStep(step *IntegrationStep) error
- func (m *MockIntegrationTester) ExecuteTest(test *IntegrationTest) *TestCaseResult
- func (m *MockIntegrationTester) ExecuteWorkflow(steps []IntegrationStep) error
- func (m *MockIntegrationTester) GetName() string
- func (m *MockIntegrationTester) Initialize(cfg interface{}) error
- func (m *MockIntegrationTester) Rollback(steps []IntegrationStep) error
- type MockUITester
- func (m *MockUITester) Cleanup() error
- func (m *MockUITester) Click(selector string) error
- func (m *MockUITester) ExecuteTest(test *UITest) *TestCaseResult
- func (m *MockUITester) GetName() string
- func (m *MockUITester) GetPageSource() (string, error)
- func (m *MockUITester) GetText(selector string) (string, error)
- func (m *MockUITester) Initialize(cfg interface{}) error
- func (m *MockUITester) Navigate(url string) error
- func (m *MockUITester) TakeScreenshot(filename string) (string, error)
- func (m *MockUITester) Type(selector, text string) error
- func (m *MockUITester) WaitForElement(selector string, timeout time.Duration) error
- type ParallelRunner
- func (pr *ParallelRunner) ExecuteTestsParallel(tests []Test) (*TestResults, error)
- func (pr *ParallelRunner) GetActiveTests() int
- func (pr *ParallelRunner) GetMaxConcurrency() int
- func (pr *ParallelRunner) IsShutdown() bool
- func (pr *ParallelRunner) SetMaxConcurrency(maxConcurrency int)
- func (pr *ParallelRunner) Shutdown() error
- type ParallelRunnerConfig
- type Reporter
- type Resource
- type ResourceInfo
- type ResourceManager
- func (rm *ResourceManager) CleanupAll() error
- func (rm *ResourceManager) GetResource(resourceID string) (Resource, error)
- func (rm *ResourceManager) GetResourcesByType(resourceType ResourceType) []Resource
- func (rm *ResourceManager) GetStats() map[ResourceType]*ResourceTypeStats
- func (rm *ResourceManager) RegisterResource(resource Resource) error
- func (rm *ResourceManager) Shutdown() error
- func (rm *ResourceManager) UnregisterResource(resourceID string) error
- type ResourceManagerConfig
- type ResourceType
- type ResourceTypeStats
- type RetryConfig
- type RetryableOperation
- type SimpleTest
- type Test
- type TestAssertion
- func (ta *TestAssertion) Contains(haystack, needle string, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) Empty(object interface{}, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) Equal(expected, actual interface{}, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) Error(err error, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) False(value bool, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) GetLogs() []string
- func (ta *TestAssertion) GetStartTime() time.Time
- func (ta *TestAssertion) GetSteps() []AssertionStep
- func (ta *TestAssertion) GetSummary() (int, int)
- func (ta *TestAssertion) GetTestName() string
- func (ta *TestAssertion) HasFailures() bool
- func (ta *TestAssertion) Len(object interface{}, length int, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) Nil(value interface{}, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) NoError(err error, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) NotContains(haystack, needle string, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) NotEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) NotNil(value interface{}, msgAndArgs ...interface{}) bool
- func (ta *TestAssertion) Reset()
- func (ta *TestAssertion) True(value bool, msgAndArgs ...interface{}) bool
- type TestBuilder
- type TestCaseResult
- type TestContext
- func (tc *TestContext) AddCleanup(cleanup func() error)
- func (tc *TestContext) AssertContains(haystack, needle string, message string) bool
- func (tc *TestContext) AssertEqual(expected, actual interface{}, message string) bool
- func (tc *TestContext) AssertFalse(value bool, message string) bool
- func (tc *TestContext) AssertNil(value interface{}, message string) bool
- func (tc *TestContext) AssertNotContains(haystack, needle string, message string) bool
- func (tc *TestContext) AssertNotEqual(expected, actual interface{}, message string) bool
- func (tc *TestContext) AssertNotNil(value interface{}, message string) bool
- func (tc *TestContext) AssertTrue(value bool, message string) bool
- func (tc *TestContext) Close()
- func (tc *TestContext) Err() error
- func (tc *TestContext) GetStartTime() time.Time
- func (tc *TestContext) GetSteps() []AssertionStep
- func (tc *TestContext) GetTestName() string
- func (tc *TestContext) GetTimeout() time.Duration
- func (tc *TestContext) HasFailures() bool
- func (tc *TestContext) ToTestCaseResult() *TestCaseResult
- type TestExecutionError
- type TestExecutor
- func (te *TestExecutor) Assert() *assertions.Asserter
- func (te *TestExecutor) Complete() *TestCaseResult
- func (te *TestExecutor) GetDuration() time.Duration
- func (te *TestExecutor) GetLogs() []string
- func (te *TestExecutor) GetTestName() string
- func (te *TestExecutor) Log(message string)
- func (te *TestExecutor) Logf(format string, args ...interface{})
- func (te *TestExecutor) Reset(testName string)
- type TestResults
- type TestSetupError
- type TestStatus
- type TestSuite
- type TestSuiteBuilder
- func (tsb *TestSuiteBuilder) AddTest(test Test) *TestSuiteBuilder
- func (tsb *TestSuiteBuilder) AddTestFunc(name string, testFunc func(*TestContext)) *TestSuiteBuilder
- func (tsb *TestSuiteBuilder) Build() *TestSuite
- func (tsb *TestSuiteBuilder) WithMaxWorkers(maxWorkers int) *TestSuiteBuilder
- func (tsb *TestSuiteBuilder) WithParallel(parallel bool) *TestSuiteBuilder
- func (tsb *TestSuiteBuilder) WithSetup(setupFunc func() error) *TestSuiteBuilder
- func (tsb *TestSuiteBuilder) WithTeardown(teardownFunc func() error) *TestSuiteBuilder
- func (tsb *TestSuiteBuilder) WithTimeout(timeout time.Duration) *TestSuiteBuilder
- type TestSuiteManager
- func (tsm *TestSuiteManager) ClearTests()
- func (tsm *TestSuiteManager) ExecuteTestByName(testName string) (*TestCaseResult, error)
- func (tsm *TestSuiteManager) ExecuteTestSuite() (*TestResults, error)
- func (tsm *TestSuiteManager) GetResults() *TestResults
- func (tsm *TestSuiteManager) GetTestCount() int
- func (tsm *TestSuiteManager) GetTestNames() []string
- func (tsm *TestSuiteManager) GetTestSuite() *TestSuite
- func (tsm *TestSuiteManager) RegisterTest(test Test)
- func (tsm *TestSuiteManager) RegisterTests(tests []Test)
- func (tsm *TestSuiteManager) SetSetupFunc(setupFunc func() error)
- func (tsm *TestSuiteManager) SetTeardownFunc(teardownFunc func() error)
- type TestSuiteResults
- type Tester
- type Transaction
- type UIAction
- type UIAssertion
- type UIStepAction
- type UITest
- type UITester
- type VersionInfo
Constants ¶
const ( TestStatusPassed = assertions.TestStatusPassed TestStatusFailed = assertions.TestStatusFailed TestStatusSkipped = assertions.TestStatusSkipped TestStatusError = assertions.TestStatusError )
Re-export constants from assertions package
const ( // Version is the current version of the Gowright framework Version = "1.1.0" // GitCommit is the git commit hash (set during build) GitCommit = "unknown" // BuildDate is the build date (set during build) BuildDate = "unknown" )
Version information for the Gowright framework
Variables ¶
This section is empty.
Functions ¶
func GetErrorContext ¶
GetErrorContext extracts context from a GowrightError
func GetVersionString ¶
func GetVersionString() string
GetVersionString returns a formatted version string
func IsGowrightError ¶
IsGowrightError checks if an error is a GowrightError
func RetryWithBackoff ¶
func RetryWithBackoff(ctx context.Context, config *RetryConfig, operation RetryableOperation) error
RetryWithBackoff executes an operation with exponential backoff retry logic
Types ¶
type APIErrorRecovery ¶
type APIErrorRecovery struct {
// contains filtered or unexported fields
}
APIErrorRecovery handles API-related error recovery
func NewAPIErrorRecovery ¶
func NewAPIErrorRecovery(config *RetryConfig) *APIErrorRecovery
NewAPIErrorRecovery creates a new API error recovery strategy
func (*APIErrorRecovery) CanRecover ¶
func (aer *APIErrorRecovery) CanRecover(err error) bool
CanRecover checks if the error can be recovered by this strategy
type APIExpectation ¶
type APIExpectation struct {
StatusCode int `json:"status_code"`
Headers map[string]string `json:"headers,omitempty"`
Body interface{} `json:"body,omitempty"`
JSONPath map[string]interface{} `json:"json_path,omitempty"`
}
APIExpectation represents expected API response
type APIResponse ¶
type APIResponse struct {
StatusCode int `json:"status_code"`
Headers map[string]string `json:"headers"`
Body []byte `json:"body"`
JSON map[string]interface{} `json:"json,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
}
APIResponse represents an HTTP response
type APIStepAction ¶
type APIStepAction struct {
Method string `json:"method"`
Endpoint string `json:"endpoint"`
Headers map[string]string `json:"headers,omitempty"`
Body interface{} `json:"body,omitempty"`
}
APIStepAction represents an API action in an integration step
func (*APIStepAction) GetType ¶
func (asa *APIStepAction) GetType() string
GetType returns the action type
type APIStepValidation ¶
type APIStepValidation struct {
ExpectedStatusCode int `json:"expected_status_code,omitempty"`
ExpectedHeaders map[string]string `json:"expected_headers,omitempty"`
ExpectedBody interface{} `json:"expected_body,omitempty"`
JSONPath map[string]interface{} `json:"json_path,omitempty"`
}
APIStepValidation represents validation criteria for API responses
func (*APIStepValidation) GetType ¶
func (asv *APIStepValidation) GetType() string
GetType returns the validation type
type APITest ¶
type APITest struct {
Name string `json:"name"`
Method string `json:"method"`
Endpoint string `json:"endpoint"`
Headers map[string]string `json:"headers,omitempty"`
Body interface{} `json:"body,omitempty"`
Expected *APIExpectation `json:"expected"`
}
APITest represents an API test case
type APITester ¶
type APITester interface {
Tester
// Get performs a GET request to the specified endpoint
Get(endpoint string, headers map[string]string) (*APIResponse, error)
// Post performs a POST request to the specified endpoint
Post(endpoint string, body interface{}, headers map[string]string) (*APIResponse, error)
// Put performs a PUT request to the specified endpoint
Put(endpoint string, body interface{}, headers map[string]string) (*APIResponse, error)
// Delete performs a DELETE request to the specified endpoint
Delete(endpoint string, headers map[string]string) (*APIResponse, error)
// SetAuth sets authentication for API requests
SetAuth(auth *config.AuthConfig) error
// ExecuteTest executes an API test and returns the result
ExecuteTest(test *APITest) *TestCaseResult
}
APITester interface defines methods for API testing capabilities
type AssertionStep ¶
type AssertionStep = assertions.AssertionStep
type BrowserErrorRecovery ¶
type BrowserErrorRecovery struct {
// contains filtered or unexported fields
}
BrowserErrorRecovery handles browser-related error recovery
func NewBrowserErrorRecovery ¶
func NewBrowserErrorRecovery(config *RetryConfig) *BrowserErrorRecovery
NewBrowserErrorRecovery creates a new browser error recovery strategy
func (*BrowserErrorRecovery) CanRecover ¶
func (ber *BrowserErrorRecovery) CanRecover(err error) bool
CanRecover checks if the error can be recovered by this strategy
type CleanupConfig ¶
type CleanupConfig struct {
DefaultTimeout time.Duration `json:"default_timeout"`
MaxConcurrent int `json:"max_concurrent"`
ContinueOnError bool `json:"continue_on_error"`
ForceGC bool `json:"force_gc"`
GCInterval time.Duration `json:"gc_interval"`
EnableMetrics bool `json:"enable_metrics"`
}
CleanupConfig holds configuration for cleanup operations
func DefaultCleanupConfig ¶
func DefaultCleanupConfig() *CleanupConfig
DefaultCleanupConfig returns default cleanup configuration
type CleanupFunc ¶
type CleanupFunc struct {
Name string
Function func() error
Priority int // Higher priority runs first
Timeout time.Duration
}
CleanupFunc represents a cleanup function
type CleanupManager ¶
type CleanupManager struct {
// contains filtered or unexported fields
}
CleanupManager handles cleanup operations for test resources
func NewCleanupManager ¶
func NewCleanupManager(config *CleanupConfig) *CleanupManager
NewCleanupManager creates a new cleanup manager
func (*CleanupManager) ExecuteCleanup ¶
func (cm *CleanupManager) ExecuteCleanup() *CleanupMetrics
ExecuteCleanup executes all registered cleanup functions
func (*CleanupManager) RegisterCleanup ¶
func (cm *CleanupManager) RegisterCleanup(name string, fn func() error, priority int)
RegisterCleanup registers a cleanup function
func (*CleanupManager) RegisterCleanupWithTimeout ¶
func (cm *CleanupManager) RegisterCleanupWithTimeout(name string, fn func() error, priority int, timeout time.Duration)
RegisterCleanupWithTimeout registers a cleanup function with a specific timeout
func (*CleanupManager) Shutdown ¶
func (cm *CleanupManager) Shutdown() *CleanupMetrics
Shutdown shuts down the cleanup manager and executes all cleanup functions
type CleanupMetrics ¶
type CleanupMetrics struct {
TotalCleanups int `json:"total_cleanups"`
SuccessfulCleanups int `json:"successful_cleanups"`
FailedCleanups int `json:"failed_cleanups"`
AverageTime time.Duration `json:"average_time"`
LastCleanupTime time.Time `json:"last_cleanup_time"`
Errors []string `json:"errors,omitempty"`
}
CleanupMetrics holds metrics about cleanup operations
type DatabaseErrorRecovery ¶
type DatabaseErrorRecovery struct {
// contains filtered or unexported fields
}
DatabaseErrorRecovery handles database-related error recovery
func NewDatabaseErrorRecovery ¶
func NewDatabaseErrorRecovery(config *RetryConfig) *DatabaseErrorRecovery
NewDatabaseErrorRecovery creates a new database error recovery strategy
func (*DatabaseErrorRecovery) CanRecover ¶
func (der *DatabaseErrorRecovery) CanRecover(err error) bool
CanRecover checks if the error can be recovered by this strategy
type DatabaseExpectation ¶
type DatabaseExpectation struct {
RowCount int `json:"row_count,omitempty"`
Rows []map[string]interface{} `json:"rows,omitempty"`
RowsAffected int64 `json:"rows_affected,omitempty"`
}
DatabaseExpectation represents expected database results
type DatabaseResult ¶
type DatabaseResult struct {
Rows []map[string]interface{} `json:"rows"`
RowCount int `json:"row_count"`
RowsAffected int64 `json:"rows_affected"`
Duration time.Duration `json:"duration"`
}
DatabaseResult represents a database query result
type DatabaseStepAction ¶
type DatabaseStepAction struct {
Connection string `json:"connection"`
Query string `json:"query"`
Args []interface{} `json:"args,omitempty"`
}
DatabaseStepAction represents a database action in an integration step
func (*DatabaseStepAction) GetType ¶
func (dsa *DatabaseStepAction) GetType() string
GetType returns the action type
type DatabaseStepValidation ¶
type DatabaseStepValidation struct {
ExpectedRowCount *int `json:"expected_row_count,omitempty"`
ExpectedRows []map[string]interface{} `json:"expected_rows,omitempty"`
ExpectedAffected *int64 `json:"expected_affected,omitempty"`
}
DatabaseStepValidation represents validation criteria for database results
func (*DatabaseStepValidation) GetType ¶
func (dsv *DatabaseStepValidation) GetType() string
GetType returns the validation type
type DatabaseTest ¶
type DatabaseTest struct {
Name string `json:"name"`
Connection string `json:"connection"`
Setup []string `json:"setup,omitempty"`
Query string `json:"query"`
Expected *DatabaseExpectation `json:"expected"`
Teardown []string `json:"teardown,omitempty"`
}
DatabaseTest represents a database test case
type DatabaseTester ¶
type DatabaseTester interface {
Tester
// Connect establishes a connection to the database
Connect(connectionName string) error
// Execute executes a SQL query and returns the result
Execute(connectionName, query string, args ...interface{}) (*DatabaseResult, error)
// BeginTransaction starts a new database transaction
BeginTransaction(connectionName string) (Transaction, error)
// ValidateData validates data against expected results
ValidateData(connectionName, query string, expected interface{}) error
// ExecuteTest executes a database test and returns the result
ExecuteTest(test *DatabaseTest) *TestCaseResult
}
DatabaseTester interface defines methods for database testing capabilities
type EnhancedFunctionTest ¶
type EnhancedFunctionTest struct {
// contains filtered or unexported fields
}
EnhancedFunctionTest is an enhanced version of FunctionTest with setup/teardown
func (*EnhancedFunctionTest) Execute ¶
func (eft *EnhancedFunctionTest) Execute() *TestCaseResult
Execute runs the enhanced function test
func (*EnhancedFunctionTest) GetName ¶
func (eft *EnhancedFunctionTest) GetName() string
GetName returns the test name
type ErrorRecoveryManager ¶
type ErrorRecoveryManager struct {
// contains filtered or unexported fields
}
ErrorRecoveryManager manages multiple recovery strategies
func NewErrorRecoveryManager ¶
func NewErrorRecoveryManager() *ErrorRecoveryManager
NewErrorRecoveryManager creates a new error recovery manager
func (*ErrorRecoveryManager) AddStrategy ¶
func (erm *ErrorRecoveryManager) AddStrategy(strategy ErrorRecoveryStrategy)
AddStrategy adds a new recovery strategy
func (*ErrorRecoveryManager) RecoverFromError ¶
func (erm *ErrorRecoveryManager) RecoverFromError(ctx context.Context, err error) error
RecoverFromError attempts to recover from an error using available strategies
type ErrorRecoveryStrategy ¶
type ErrorRecoveryStrategy interface {
CanRecover(err error) bool
Recover(ctx context.Context, err error) error
}
ErrorRecoveryStrategy defines how to recover from specific error types
type ErrorType ¶
type ErrorType int
ErrorType represents different types of framework errors
func GetErrorType ¶
GetErrorType extracts the error type from a GowrightError
type FunctionTest ¶
type FunctionTest struct {
// contains filtered or unexported fields
}
FunctionTest implements the Test interface for function-based tests
func (*FunctionTest) Execute ¶
func (ft *FunctionTest) Execute() *TestCaseResult
Execute runs the function test
func (*FunctionTest) GetName ¶
func (ft *FunctionTest) GetName() string
GetName returns the test name
type FunctionTestBuilder ¶
type FunctionTestBuilder struct {
// contains filtered or unexported fields
}
TestBuilder provides a fluent interface for building tests
func NewFunctionTestBuilder ¶
func NewFunctionTestBuilder(name string) *FunctionTestBuilder
NewFunctionTestBuilder creates a new function test builder
func (*FunctionTestBuilder) Build ¶
func (tb *FunctionTestBuilder) Build() Test
Build creates the test
func (*FunctionTestBuilder) WithRetries ¶
func (tb *FunctionTestBuilder) WithRetries(retries int) *FunctionTestBuilder
WithRetries sets the number of retries
func (*FunctionTestBuilder) WithSetup ¶
func (tb *FunctionTestBuilder) WithSetup(setup func() error) *FunctionTestBuilder
WithSetup sets the setup function
func (*FunctionTestBuilder) WithTeardown ¶
func (tb *FunctionTestBuilder) WithTeardown(teardown func() error) *FunctionTestBuilder
WithTeardown sets the teardown function
func (*FunctionTestBuilder) WithTestFunc ¶
func (tb *FunctionTestBuilder) WithTestFunc(testFunc func(*TestContext)) *FunctionTestBuilder
WithTestFunc sets the test function
func (*FunctionTestBuilder) WithTimeout ¶
func (tb *FunctionTestBuilder) WithTimeout(timeout time.Duration) *FunctionTestBuilder
WithTimeout sets the test timeout
type Gowright ¶
type Gowright struct {
// contains filtered or unexported fields
}
Gowright is the main framework struct that orchestrates all testing activities
func NewWithDefaults ¶
func NewWithDefaults() *Gowright
NewWithDefaults creates a new Gowright instance with default configuration
func NewWithOptions ¶
func NewWithOptions(options *GowrightOptions) *Gowright
NewWithOptions creates a new Gowright instance with dependency injection support
func (*Gowright) ExecuteAPITest ¶
func (g *Gowright) ExecuteAPITest(test *APITest) *TestCaseResult
ExecuteAPITest executes a single API test and returns the result
func (*Gowright) ExecuteDatabaseTest ¶
func (g *Gowright) ExecuteDatabaseTest(test *DatabaseTest) *TestCaseResult
ExecuteDatabaseTest executes a single database test and returns the result
func (*Gowright) ExecuteIntegrationTest ¶
func (g *Gowright) ExecuteIntegrationTest(test *IntegrationTest) *TestCaseResult
ExecuteIntegrationTest executes a single integration test and returns the result
func (*Gowright) ExecuteUITest ¶
func (g *Gowright) ExecuteUITest(test *UITest) *TestCaseResult
ExecuteUITest executes a single UI test and returns the result
func (*Gowright) GetAPITester ¶
GetAPITester returns the API tester instance
func (*Gowright) GetDatabaseTester ¶
func (g *Gowright) GetDatabaseTester() DatabaseTester
GetDatabaseTester returns the database tester instance
func (*Gowright) GetIntegrationTester ¶
func (g *Gowright) GetIntegrationTester() IntegrationTester
GetIntegrationTester returns the integration tester instance
func (*Gowright) GetTestSuite ¶
GetTestSuite returns the current test suite
func (*Gowright) GetUITester ¶
GetUITester returns the UI tester instance
func (*Gowright) Initialize ¶
Initialize initializes the framework and all its components
func (*Gowright) IsInitialized ¶
IsInitialized returns whether the framework has been initialized
func (*Gowright) SetAPITester ¶
SetAPITester sets the API tester instance
func (*Gowright) SetDatabaseTester ¶
func (g *Gowright) SetDatabaseTester(tester DatabaseTester)
SetDatabaseTester sets the database tester instance
func (*Gowright) SetIntegrationTester ¶
func (g *Gowright) SetIntegrationTester(tester IntegrationTester)
SetIntegrationTester sets the integration tester instance
func (*Gowright) SetTestSuite ¶
SetTestSuite sets the test suite for this Gowright instance
func (*Gowright) SetUITester ¶
SetUITester sets the UI tester instance
type GowrightError ¶
type GowrightError struct {
Type ErrorType `json:"type"`
Message string `json:"message"`
Cause error `json:"cause,omitempty"`
Context map[string]interface{} `json:"context,omitempty"`
}
GowrightError represents framework-specific errors
func NewGowrightError ¶
func NewGowrightError(errorType ErrorType, message string, cause error) *GowrightError
NewGowrightError creates a new GowrightError
func WrapError ¶
func WrapError(errorType ErrorType, message string, cause error) *GowrightError
WrapError wraps a generic error into a GowrightError with context
func WrapErrorWithContext ¶
func WrapErrorWithContext(errorType ErrorType, message string, cause error, context map[string]interface{}) *GowrightError
WrapErrorWithContext wraps an error and adds context information
func (*GowrightError) Error ¶
func (ge *GowrightError) Error() string
Error implements the error interface
func (*GowrightError) WithContext ¶
func (ge *GowrightError) WithContext(key string, value interface{}) *GowrightError
WithContext adds context information to the error
type GowrightOptions ¶
type GowrightOptions struct {
Config *config.Config
UITester UITester
APITester APITester
DatabaseTester DatabaseTester
IntegrationTester IntegrationTester
}
GowrightOptions provides options for creating a Gowright instance
type IntegrationStep ¶
type IntegrationStep struct {
Name string `json:"name"`
Type IntegrationStepType `json:"type"`
Action interface{} `json:"action"`
Validation interface{} `json:"validation,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
RetryCount int `json:"retry_count,omitempty"`
}
IntegrationStep represents a single step in an integration test
type IntegrationStepAction ¶
type IntegrationStepAction interface {
GetType() string
}
IntegrationStepAction is an interface for different types of step actions
type IntegrationStepType ¶
type IntegrationStepType int
IntegrationStepType represents the type of integration step
const ( StepTypeUI IntegrationStepType = iota StepTypeAPI StepTypeDatabase StepTypeMobile )
func (IntegrationStepType) String ¶
func (ist IntegrationStepType) String() string
String returns the string representation of IntegrationStepType
type IntegrationStepValidation ¶
type IntegrationStepValidation interface {
GetType() string
}
IntegrationStepValidation is an interface for different types of step validations
type IntegrationTest ¶
type IntegrationTest struct {
Name string `json:"name"`
Steps []IntegrationStep `json:"steps"`
Rollback []IntegrationStep `json:"rollback,omitempty"`
}
IntegrationTest represents a complex integration test
type IntegrationTester ¶
type IntegrationTester interface {
Tester
// ExecuteStep executes a single integration step
ExecuteStep(step *IntegrationStep) error
// ExecuteWorkflow executes a complete integration workflow
ExecuteWorkflow(steps []IntegrationStep) error
// Rollback performs rollback operations for failed tests
Rollback(steps []IntegrationStep) error
// ExecuteTest executes an integration test and returns the result
ExecuteTest(test *IntegrationTest) *TestCaseResult
}
IntegrationTester interface defines methods for integration testing
func NewIntegrationTesterFromComponents ¶
func NewIntegrationTesterFromComponents(uiTester UITester, apiTester APITester, dbTester DatabaseTester) IntegrationTester
NewIntegrationTesterFromComponents creates a new integration tester from components
type MockAPITester ¶
MockAPITester is a mock implementation of APITester for testing
func NewMockAPITester ¶
func NewMockAPITester() *MockAPITester
NewMockAPITester creates a new mock API tester
func (*MockAPITester) Cleanup ¶
func (m *MockAPITester) Cleanup() error
Cleanup cleans up the mock API tester
func (*MockAPITester) Delete ¶
func (m *MockAPITester) Delete(endpoint string, headers map[string]string) (*APIResponse, error)
Delete performs a DELETE request
func (*MockAPITester) ExecuteTest ¶
func (m *MockAPITester) ExecuteTest(test *APITest) *TestCaseResult
ExecuteTest executes an API test
func (*MockAPITester) Get ¶
func (m *MockAPITester) Get(endpoint string, headers map[string]string) (*APIResponse, error)
Get performs a GET request
func (*MockAPITester) GetName ¶
func (m *MockAPITester) GetName() string
GetName returns the name of the mock API tester
func (*MockAPITester) Initialize ¶
func (m *MockAPITester) Initialize(cfg interface{}) error
Initialize initializes the mock API tester
func (*MockAPITester) Post ¶
func (m *MockAPITester) Post(endpoint string, body interface{}, headers map[string]string) (*APIResponse, error)
Post performs a POST request
func (*MockAPITester) Put ¶
func (m *MockAPITester) Put(endpoint string, body interface{}, headers map[string]string) (*APIResponse, error)
Put performs a PUT request
func (*MockAPITester) SetAuth ¶
func (m *MockAPITester) SetAuth(auth *config.AuthConfig) error
SetAuth sets authentication
type MockDatabaseTester ¶
MockDatabaseTester is a mock implementation of DatabaseTester for testing
func NewMockDatabaseTester ¶
func NewMockDatabaseTester() *MockDatabaseTester
NewMockDatabaseTester creates a new mock database tester
func (*MockDatabaseTester) BeginTransaction ¶
func (m *MockDatabaseTester) BeginTransaction(connectionName string) (Transaction, error)
BeginTransaction begins a database transaction
func (*MockDatabaseTester) Cleanup ¶
func (m *MockDatabaseTester) Cleanup() error
Cleanup cleans up the mock database tester
func (*MockDatabaseTester) Connect ¶
func (m *MockDatabaseTester) Connect(connectionName string) error
Connect connects to a database
func (*MockDatabaseTester) Execute ¶
func (m *MockDatabaseTester) Execute(connectionName, query string, args ...interface{}) (*DatabaseResult, error)
Execute executes a database query
func (*MockDatabaseTester) ExecuteTest ¶
func (m *MockDatabaseTester) ExecuteTest(test *DatabaseTest) *TestCaseResult
ExecuteTest executes a database test
func (*MockDatabaseTester) GetName ¶
func (m *MockDatabaseTester) GetName() string
GetName returns the name of the mock database tester
func (*MockDatabaseTester) Initialize ¶
func (m *MockDatabaseTester) Initialize(cfg interface{}) error
Initialize initializes the mock database tester
func (*MockDatabaseTester) ValidateData ¶
func (m *MockDatabaseTester) ValidateData(connectionName, query string, expected interface{}) error
ValidateData validates database data
type MockIntegrationTester ¶
MockIntegrationTester is a mock implementation of IntegrationTester for testing
func NewMockIntegrationTester ¶
func NewMockIntegrationTester() *MockIntegrationTester
NewMockIntegrationTester creates a new mock integration tester
func (*MockIntegrationTester) Cleanup ¶
func (m *MockIntegrationTester) Cleanup() error
Cleanup cleans up the mock integration tester
func (*MockIntegrationTester) ExecuteStep ¶
func (m *MockIntegrationTester) ExecuteStep(step *IntegrationStep) error
ExecuteStep executes an integration step
func (*MockIntegrationTester) ExecuteTest ¶
func (m *MockIntegrationTester) ExecuteTest(test *IntegrationTest) *TestCaseResult
ExecuteTest executes an integration test
func (*MockIntegrationTester) ExecuteWorkflow ¶
func (m *MockIntegrationTester) ExecuteWorkflow(steps []IntegrationStep) error
ExecuteWorkflow executes an integration workflow
func (*MockIntegrationTester) GetName ¶
func (m *MockIntegrationTester) GetName() string
GetName returns the name of the mock integration tester
func (*MockIntegrationTester) Initialize ¶
func (m *MockIntegrationTester) Initialize(cfg interface{}) error
Initialize initializes the mock integration tester
func (*MockIntegrationTester) Rollback ¶
func (m *MockIntegrationTester) Rollback(steps []IntegrationStep) error
Rollback performs rollback operations
type MockUITester ¶
MockUITester is a mock implementation of UITester for testing
func NewMockUITester ¶
func NewMockUITester() *MockUITester
NewMockUITester creates a new mock UI tester
func (*MockUITester) Cleanup ¶
func (m *MockUITester) Cleanup() error
Cleanup cleans up the mock UI tester
func (*MockUITester) Click ¶
func (m *MockUITester) Click(selector string) error
Click clicks on an element
func (*MockUITester) ExecuteTest ¶
func (m *MockUITester) ExecuteTest(test *UITest) *TestCaseResult
ExecuteTest executes a UI test
func (*MockUITester) GetName ¶
func (m *MockUITester) GetName() string
GetName returns the name of the mock UI tester
func (*MockUITester) GetPageSource ¶
func (m *MockUITester) GetPageSource() (string, error)
GetPageSource gets the page source
func (*MockUITester) GetText ¶
func (m *MockUITester) GetText(selector string) (string, error)
GetText gets text from an element
func (*MockUITester) Initialize ¶
func (m *MockUITester) Initialize(cfg interface{}) error
Initialize initializes the mock UI tester
func (*MockUITester) Navigate ¶
func (m *MockUITester) Navigate(url string) error
Navigate navigates to a URL
func (*MockUITester) TakeScreenshot ¶
func (m *MockUITester) TakeScreenshot(filename string) (string, error)
TakeScreenshot takes a screenshot
func (*MockUITester) Type ¶
func (m *MockUITester) Type(selector, text string) error
Type types text into an element
func (*MockUITester) WaitForElement ¶
func (m *MockUITester) WaitForElement(selector string, timeout time.Duration) error
WaitForElement waits for an element to be present
type ParallelRunner ¶
type ParallelRunner struct {
// contains filtered or unexported fields
}
ParallelRunner manages concurrent test execution with resource management
func NewParallelRunner ¶
func NewParallelRunner(cfg *config.Config, runnerConfig *ParallelRunnerConfig) *ParallelRunner
NewParallelRunner creates a new parallel test runner
func (*ParallelRunner) ExecuteTestsParallel ¶
func (pr *ParallelRunner) ExecuteTestsParallel(tests []Test) (*TestResults, error)
ExecuteTestsParallel executes tests in parallel with concurrency control
func (*ParallelRunner) GetActiveTests ¶
func (pr *ParallelRunner) GetActiveTests() int
GetActiveTests returns the number of currently running tests
func (*ParallelRunner) GetMaxConcurrency ¶
func (pr *ParallelRunner) GetMaxConcurrency() int
GetMaxConcurrency returns the maximum concurrency level
func (*ParallelRunner) IsShutdown ¶
func (pr *ParallelRunner) IsShutdown() bool
IsShutdown returns whether the runner has been shut down
func (*ParallelRunner) SetMaxConcurrency ¶
func (pr *ParallelRunner) SetMaxConcurrency(maxConcurrency int)
SetMaxConcurrency sets the maximum concurrency level
func (*ParallelRunner) Shutdown ¶
func (pr *ParallelRunner) Shutdown() error
Shutdown gracefully shuts down the parallel runner
type ParallelRunnerConfig ¶
type ParallelRunnerConfig struct {
MaxConcurrency int `json:"max_concurrency"`
ResourceTimeout time.Duration `json:"resource_timeout"`
BrowserPoolSize int `json:"browser_pool_size"`
DatabasePoolSize int `json:"database_pool_size"`
HTTPClientPoolSize int `json:"http_client_pool_size"`
GracefulShutdown time.Duration `json:"graceful_shutdown"`
}
ParallelRunnerConfig holds configuration for parallel test execution
func DefaultParallelRunnerConfig ¶
func DefaultParallelRunnerConfig() *ParallelRunnerConfig
DefaultParallelRunnerConfig returns default configuration for parallel runner
type Reporter ¶
type Reporter interface {
// GenerateReport generates a report from test results
GenerateReport(results *TestResults) error
// GetName returns the name of the reporter
GetName() string
// IsEnabled returns whether this reporter is enabled
IsEnabled() bool
}
Reporter interface defines methods for test result reporting
type Resource ¶
type Resource interface {
GetID() string
GetType() ResourceType
GetCreatedAt() time.Time
GetLastUsed() time.Time
IsActive() bool
Cleanup() error
}
Resource represents a managed resource
type ResourceInfo ¶
type ResourceInfo struct {
ID string `json:"id"`
Type ResourceType `json:"type"`
CreatedAt time.Time `json:"created_at"`
LastUsed time.Time `json:"last_used"`
Active bool `json:"active"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
ResourceInfo holds information about a resource
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager manages the lifecycle of test resources
func NewResourceManager ¶
func NewResourceManager(config *ResourceManagerConfig) *ResourceManager
NewResourceManager creates a new resource manager
func (*ResourceManager) CleanupAll ¶
func (rm *ResourceManager) CleanupAll() error
CleanupAll cleans up all resources
func (*ResourceManager) GetResource ¶
func (rm *ResourceManager) GetResource(resourceID string) (Resource, error)
GetResource retrieves a resource by ID
func (*ResourceManager) GetResourcesByType ¶
func (rm *ResourceManager) GetResourcesByType(resourceType ResourceType) []Resource
GetResourcesByType retrieves all resources of a specific type
func (*ResourceManager) GetStats ¶
func (rm *ResourceManager) GetStats() map[ResourceType]*ResourceTypeStats
GetStats returns resource statistics
func (*ResourceManager) RegisterResource ¶
func (rm *ResourceManager) RegisterResource(resource Resource) error
RegisterResource registers a new resource
func (*ResourceManager) Shutdown ¶
func (rm *ResourceManager) Shutdown() error
Shutdown shuts down the resource manager
func (*ResourceManager) UnregisterResource ¶
func (rm *ResourceManager) UnregisterResource(resourceID string) error
UnregisterResource unregisters a resource
type ResourceManagerConfig ¶
type ResourceManagerConfig struct {
MaxResources int `json:"max_resources"`
CleanupInterval time.Duration `json:"cleanup_interval"`
ResourceTimeout time.Duration `json:"resource_timeout"`
MaxIdleTime time.Duration `json:"max_idle_time"`
EnableLeakDetection bool `json:"enable_leak_detection"`
LeakDetectionInterval time.Duration `json:"leak_detection_interval"`
}
ResourceManagerConfig holds configuration for resource management
func DefaultResourceManagerConfig ¶
func DefaultResourceManagerConfig() *ResourceManagerConfig
DefaultResourceManagerConfig returns default configuration
type ResourceType ¶
type ResourceType string
ResourceType represents different types of resources
const ( ResourceTypeBrowser ResourceType = "browser" ResourceTypeDatabase ResourceType = "database" ResourceTypeHTTPClient ResourceType = "http_client" ResourceTypeMobile ResourceType = "mobile" ResourceTypeFile ResourceType = "file" ResourceTypeMemory ResourceType = "memory" )
type ResourceTypeStats ¶
type ResourceTypeStats struct {
Type ResourceType `json:"type"`
Active int `json:"active"`
Total int `json:"total"`
Created int `json:"created"`
Cleaned int `json:"cleaned"`
Leaked int `json:"leaked"`
LastActivity time.Time `json:"last_activity"`
}
ResourceTypeStats holds statistics for a resource type
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int `json:"max_retries"`
InitialDelay time.Duration `json:"initial_delay"`
MaxDelay time.Duration `json:"max_delay"`
BackoffFactor float64 `json:"backoff_factor"`
RetryableErrors []ErrorType `json:"retryable_errors"`
}
RetryConfig defines retry behavior for different operations
func DefaultRetryConfig ¶
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns default retry configuration
func (*RetryConfig) CalculateDelay ¶
func (rc *RetryConfig) CalculateDelay(attempt int) time.Duration
CalculateDelay calculates the delay for a given retry attempt using exponential backoff
func (*RetryConfig) IsRetryable ¶
func (rc *RetryConfig) IsRetryable(errorType ErrorType) bool
IsRetryable checks if an error type is retryable
type RetryableOperation ¶
type RetryableOperation func() error
RetryableOperation represents an operation that can be retried
type SimpleTest ¶
type SimpleTest struct {
// contains filtered or unexported fields
}
SimpleTest is a basic implementation of the Test interface for testing
func NewSimpleTest ¶
func NewSimpleTest(name string, testFunc func() *TestCaseResult) *SimpleTest
NewSimpleTest creates a new simple test
func (*SimpleTest) Execute ¶
func (st *SimpleTest) Execute() *TestCaseResult
Execute runs the test function
type Test ¶
type Test interface {
GetName() string
Execute() *TestCaseResult
}
Test represents a generic test interface
func NewFunctionTest ¶
func NewFunctionTest(name string, testFunc func(*TestContext)) Test
NewFunctionTest creates a new function-based test
type TestAssertion ¶
type TestAssertion struct {
// contains filtered or unexported fields
}
TestAssertion provides assertion capabilities for tests
func NewTestAssertion ¶
func NewTestAssertion(testName string) *TestAssertion
NewTestAssertion creates a new test assertion instance
func (*TestAssertion) Contains ¶
func (ta *TestAssertion) Contains(haystack, needle string, msgAndArgs ...interface{}) bool
Contains asserts that a string contains a substring
func (*TestAssertion) Empty ¶
func (ta *TestAssertion) Empty(object interface{}, msgAndArgs ...interface{}) bool
Empty asserts that an object is empty
func (*TestAssertion) Equal ¶
func (ta *TestAssertion) Equal(expected, actual interface{}, msgAndArgs ...interface{}) bool
Equal asserts that two values are equal
func (*TestAssertion) Error ¶
func (ta *TestAssertion) Error(err error, msgAndArgs ...interface{}) bool
Error asserts that an error is not nil
func (*TestAssertion) False ¶
func (ta *TestAssertion) False(value bool, msgAndArgs ...interface{}) bool
False asserts that a value is false
func (*TestAssertion) GetLogs ¶
func (ta *TestAssertion) GetLogs() []string
GetLogs returns all log entries (placeholder implementation)
func (*TestAssertion) GetStartTime ¶
func (ta *TestAssertion) GetStartTime() time.Time
GetStartTime returns the test start time
func (*TestAssertion) GetSteps ¶
func (ta *TestAssertion) GetSteps() []AssertionStep
GetSteps returns all assertion steps
func (*TestAssertion) GetSummary ¶
func (ta *TestAssertion) GetSummary() (int, int)
GetSummary returns the count of passed and failed assertions
func (*TestAssertion) GetTestName ¶
func (ta *TestAssertion) GetTestName() string
GetTestName returns the test name
func (*TestAssertion) HasFailures ¶
func (ta *TestAssertion) HasFailures() bool
HasFailures returns true if any assertions failed
func (*TestAssertion) Len ¶
func (ta *TestAssertion) Len(object interface{}, length int, msgAndArgs ...interface{}) bool
Len asserts that an object has the expected length
func (*TestAssertion) Nil ¶
func (ta *TestAssertion) Nil(value interface{}, msgAndArgs ...interface{}) bool
Nil asserts that a value is nil
func (*TestAssertion) NoError ¶
func (ta *TestAssertion) NoError(err error, msgAndArgs ...interface{}) bool
NoError asserts that an error is nil
func (*TestAssertion) NotContains ¶
func (ta *TestAssertion) NotContains(haystack, needle string, msgAndArgs ...interface{}) bool
NotContains asserts that a string does not contain a substring
func (*TestAssertion) NotEmpty ¶
func (ta *TestAssertion) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool
NotEmpty asserts that an object is not empty
func (*TestAssertion) NotEqual ¶
func (ta *TestAssertion) NotEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool
NotEqual asserts that two values are not equal
func (*TestAssertion) NotNil ¶
func (ta *TestAssertion) NotNil(value interface{}, msgAndArgs ...interface{}) bool
NotNil asserts that a value is not nil
func (*TestAssertion) True ¶
func (ta *TestAssertion) True(value bool, msgAndArgs ...interface{}) bool
True asserts that a value is true
type TestBuilder ¶
type TestBuilder struct {
// contains filtered or unexported fields
}
TestBuilder provides a fluent interface for building tests
func NewTestBuilder ¶
func NewTestBuilder(name string) *TestBuilder
NewTestBuilder creates a new test builder
func (*TestBuilder) WithCleanup ¶
func (tb *TestBuilder) WithCleanup(cleanupFunc func() error) *TestBuilder
WithCleanup sets the cleanup function
func (*TestBuilder) WithSetup ¶
func (tb *TestBuilder) WithSetup(setupFunc func() error) *TestBuilder
WithSetup sets the setup function
func (*TestBuilder) WithTest ¶
func (tb *TestBuilder) WithTest(testFunc func(*TestExecutor) error) *TestBuilder
WithTest sets the test function
type TestCaseResult ¶
type TestCaseResult struct {
Name string `json:"name"`
Status TestStatus `json:"status"`
Duration time.Duration `json:"duration"`
Error error `json:"error,omitempty"`
Screenshots []string `json:"screenshots,omitempty"`
Logs []string `json:"logs,omitempty"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Steps []AssertionStep `json:"steps,omitempty"`
}
TestCaseResult represents the result of a single test case execution
func (TestCaseResult) MarshalJSON ¶
func (tcr TestCaseResult) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for TestCaseResult
func (*TestCaseResult) UnmarshalJSON ¶
func (tcr *TestCaseResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for TestCaseResult
type TestContext ¶
type TestContext struct {
// contains filtered or unexported fields
}
TestContext provides a context for function-based tests with assertion capabilities
func NewTestContext ¶
func NewTestContext(testName string) *TestContext
NewTestContext creates a new test context
func NewTestContextWithTimeout ¶
func NewTestContextWithTimeout(testName string, timeout time.Duration) *TestContext
NewTestContextWithTimeout creates a new test context with a specific timeout
func (*TestContext) AddCleanup ¶
func (tc *TestContext) AddCleanup(cleanup func() error)
AddCleanup adds a cleanup function to be called when the test finishes
func (*TestContext) AssertContains ¶
func (tc *TestContext) AssertContains(haystack, needle string, message string) bool
AssertContains asserts that a string contains a substring
func (*TestContext) AssertEqual ¶
func (tc *TestContext) AssertEqual(expected, actual interface{}, message string) bool
AssertEqual asserts that two values are equal
func (*TestContext) AssertFalse ¶
func (tc *TestContext) AssertFalse(value bool, message string) bool
AssertFalse asserts that a value is false
func (*TestContext) AssertNil ¶
func (tc *TestContext) AssertNil(value interface{}, message string) bool
AssertNil asserts that a value is nil
func (*TestContext) AssertNotContains ¶
func (tc *TestContext) AssertNotContains(haystack, needle string, message string) bool
AssertNotContains asserts that a string does not contain a substring
func (*TestContext) AssertNotEqual ¶
func (tc *TestContext) AssertNotEqual(expected, actual interface{}, message string) bool
AssertNotEqual asserts that two values are not equal
func (*TestContext) AssertNotNil ¶
func (tc *TestContext) AssertNotNil(value interface{}, message string) bool
AssertNotNil asserts that a value is not nil
func (*TestContext) AssertTrue ¶
func (tc *TestContext) AssertTrue(value bool, message string) bool
AssertTrue asserts that a value is true
func (*TestContext) Err ¶
func (tc *TestContext) Err() error
Err returns an error if any assertions failed
func (*TestContext) GetStartTime ¶
func (tc *TestContext) GetStartTime() time.Time
GetStartTime returns the test start time
func (*TestContext) GetSteps ¶
func (tc *TestContext) GetSteps() []AssertionStep
GetSteps returns all assertion steps
func (*TestContext) GetTestName ¶
func (tc *TestContext) GetTestName() string
GetTestName returns the test name
func (*TestContext) GetTimeout ¶
func (tc *TestContext) GetTimeout() time.Duration
GetTimeout returns the test timeout
func (*TestContext) HasFailures ¶
func (tc *TestContext) HasFailures() bool
HasFailures returns true if any assertions failed
func (*TestContext) ToTestCaseResult ¶
func (tc *TestContext) ToTestCaseResult() *TestCaseResult
ToTestCaseResult converts the test context to a test case result
type TestExecutionError ¶
type TestExecutionError struct {
*GowrightError
TestName string
}
TestExecutionError represents an error that occurred during test execution
func NewTestExecutionError ¶
func NewTestExecutionError(testName, message string, cause error) *TestExecutionError
NewTestExecutionError creates a new test execution error
type TestExecutor ¶
type TestExecutor struct {
// contains filtered or unexported fields
}
TestExecutor provides a convenient way to execute tests with assertion logging
func NewTestExecutor ¶
func NewTestExecutor(testName string) *TestExecutor
NewTestExecutor creates a new test executor with assertion logging
func (*TestExecutor) Assert ¶
func (te *TestExecutor) Assert() *assertions.Asserter
Assert returns the Asserter instance for making assertions
func (*TestExecutor) Complete ¶
func (te *TestExecutor) Complete() *TestCaseResult
Complete finalizes the test execution and returns the result
func (*TestExecutor) GetDuration ¶
func (te *TestExecutor) GetDuration() time.Duration
GetDuration returns the current test duration
func (*TestExecutor) GetLogs ¶
func (te *TestExecutor) GetLogs() []string
GetLogs returns all log entries
func (*TestExecutor) GetTestName ¶
func (te *TestExecutor) GetTestName() string
GetTestName returns the test name
func (*TestExecutor) Log ¶
func (te *TestExecutor) Log(message string)
Log adds a log entry to the test
func (*TestExecutor) Logf ¶
func (te *TestExecutor) Logf(format string, args ...interface{})
Logf adds a formatted log entry to the test
func (*TestExecutor) Reset ¶
func (te *TestExecutor) Reset(testName string)
Reset resets the test executor for reuse
type TestResults ¶
type TestResults struct {
SuiteName string `json:"suite_name"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
TotalTests int `json:"total_tests"`
PassedTests int `json:"passed_tests"`
FailedTests int `json:"failed_tests"`
SkippedTests int `json:"skipped_tests"`
ErrorTests int `json:"error_tests"`
TestCases []TestCaseResult `json:"test_cases"`
}
TestResults holds all test execution results
type TestSetupError ¶
type TestSetupError struct {
*GowrightError
TestName string
}
TestSetupError represents an error that occurred during test setup
func NewTestSetupError ¶
func NewTestSetupError(testName, message string, cause error) *TestSetupError
NewTestSetupError creates a new test setup error
type TestSuite ¶
TestSuite represents a collection of tests with setup and teardown
func NewTestSuite ¶
NewTestSuite creates a new test suite with the given name
func (*TestSuite) AddTestFunc ¶
func (ts *TestSuite) AddTestFunc(name string, testFunc func(*TestContext))
AddTestFunc adds a function-based test to the test suite
func (*TestSuite) Run ¶
func (ts *TestSuite) Run() *TestSuiteResults
Run executes all tests in the suite and returns the results
type TestSuiteBuilder ¶
type TestSuiteBuilder struct {
// contains filtered or unexported fields
}
TestSuiteBuilder provides a fluent interface for building test suites
func NewTestSuiteBuilder ¶
func NewTestSuiteBuilder(name string) *TestSuiteBuilder
NewTestSuiteBuilder creates a new test suite builder
func (*TestSuiteBuilder) AddTest ¶
func (tsb *TestSuiteBuilder) AddTest(test Test) *TestSuiteBuilder
AddTest adds a test to the suite
func (*TestSuiteBuilder) AddTestFunc ¶
func (tsb *TestSuiteBuilder) AddTestFunc(name string, testFunc func(*TestContext)) *TestSuiteBuilder
AddTestFunc adds a function-based test to the suite
func (*TestSuiteBuilder) Build ¶
func (tsb *TestSuiteBuilder) Build() *TestSuite
Build creates the test suite
func (*TestSuiteBuilder) WithMaxWorkers ¶
func (tsb *TestSuiteBuilder) WithMaxWorkers(maxWorkers int) *TestSuiteBuilder
WithMaxWorkers sets the maximum number of parallel workers
func (*TestSuiteBuilder) WithParallel ¶
func (tsb *TestSuiteBuilder) WithParallel(parallel bool) *TestSuiteBuilder
WithParallel enables parallel execution
func (*TestSuiteBuilder) WithSetup ¶
func (tsb *TestSuiteBuilder) WithSetup(setupFunc func() error) *TestSuiteBuilder
WithSetup sets the setup function
func (*TestSuiteBuilder) WithTeardown ¶
func (tsb *TestSuiteBuilder) WithTeardown(teardownFunc func() error) *TestSuiteBuilder
WithTeardown sets the teardown function
func (*TestSuiteBuilder) WithTimeout ¶
func (tsb *TestSuiteBuilder) WithTimeout(timeout time.Duration) *TestSuiteBuilder
WithTimeout sets the suite timeout
type TestSuiteManager ¶
type TestSuiteManager struct {
// contains filtered or unexported fields
}
TestSuiteManager manages test suite execution and orchestration
func NewTestSuiteManager ¶
func NewTestSuiteManager(suite *TestSuite, cfg *config.Config) *TestSuiteManager
NewTestSuiteManager creates a new test suite manager
func (*TestSuiteManager) ClearTests ¶
func (tsm *TestSuiteManager) ClearTests()
ClearTests removes all registered tests
func (*TestSuiteManager) ExecuteTestByName ¶
func (tsm *TestSuiteManager) ExecuteTestByName(testName string) (*TestCaseResult, error)
ExecuteTestByName executes a specific test by name
func (*TestSuiteManager) ExecuteTestSuite ¶
func (tsm *TestSuiteManager) ExecuteTestSuite() (*TestResults, error)
ExecuteTestSuite executes the complete test suite with setup and teardown
func (*TestSuiteManager) GetResults ¶
func (tsm *TestSuiteManager) GetResults() *TestResults
GetResults returns the current test results
func (*TestSuiteManager) GetTestCount ¶
func (tsm *TestSuiteManager) GetTestCount() int
GetTestCount returns the number of registered tests
func (*TestSuiteManager) GetTestNames ¶
func (tsm *TestSuiteManager) GetTestNames() []string
GetTestNames returns the names of all registered tests
func (*TestSuiteManager) GetTestSuite ¶
func (tsm *TestSuiteManager) GetTestSuite() *TestSuite
GetTestSuite returns the test suite
func (*TestSuiteManager) RegisterTest ¶
func (tsm *TestSuiteManager) RegisterTest(test Test)
RegisterTest registers a test with the test suite
func (*TestSuiteManager) RegisterTests ¶
func (tsm *TestSuiteManager) RegisterTests(tests []Test)
RegisterTests registers multiple tests with the test suite
func (*TestSuiteManager) SetSetupFunc ¶
func (tsm *TestSuiteManager) SetSetupFunc(setupFunc func() error)
SetSetupFunc sets the setup function for the test suite
func (*TestSuiteManager) SetTeardownFunc ¶
func (tsm *TestSuiteManager) SetTeardownFunc(teardownFunc func() error)
SetTeardownFunc sets the teardown function for the test suite
type TestSuiteResults ¶
type TestSuiteResults struct {
SuiteName string `json:"suite_name"`
TestResults []*TestCaseResult `json:"test_results"`
PassedCount int `json:"passed_count"`
FailedCount int `json:"failed_count"`
ErrorCount int `json:"error_count"`
SkippedCount int `json:"skipped_count"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Duration time.Duration `json:"duration"`
}
TestSuiteResults holds the results of a test suite execution
func (*TestSuiteResults) GetFailedTests ¶
func (tsr *TestSuiteResults) GetFailedTests() []*TestCaseResult
GetFailedTests returns all failed test results
func (*TestSuiteResults) GetPassedTests ¶
func (tsr *TestSuiteResults) GetPassedTests() []*TestCaseResult
GetPassedTests returns all passed test results
func (*TestSuiteResults) GetSuccessRate ¶
func (tsr *TestSuiteResults) GetSuccessRate() float64
GetSuccessRate returns the success rate as a percentage
func (*TestSuiteResults) GetTotalCount ¶
func (tsr *TestSuiteResults) GetTotalCount() int
GetTotalCount returns the total number of tests
func (*TestSuiteResults) HasFailures ¶
func (tsr *TestSuiteResults) HasFailures() bool
HasFailures returns true if there are any failures or errors
type Tester ¶
type Tester interface {
// Initialize sets up the tester with the provided configuration
Initialize(config interface{}) error
// Cleanup performs any necessary cleanup operations
Cleanup() error
// GetName returns the name of the tester
GetName() string
}
Tester represents the base interface for all testing modules
type Transaction ¶
type Transaction interface {
// Commit commits the transaction
Commit() error
// Rollback rolls back the transaction
Rollback() error
// Execute executes a query within the transaction
Execute(query string, args ...interface{}) (*DatabaseResult, error)
}
Transaction interface defines database transaction operations
type UIAction ¶
type UIAction struct {
Type string `json:"type"`
Selector string `json:"selector,omitempty"`
Value string `json:"value,omitempty"`
Options interface{} `json:"options,omitempty"`
}
UIAction represents a UI interaction
type UIAssertion ¶
type UIAssertion struct {
Type string `json:"type"`
Selector string `json:"selector,omitempty"`
Expected interface{} `json:"expected"`
Attribute string `json:"attribute,omitempty"`
Options interface{} `json:"options,omitempty"`
}
UIAssertion represents a UI validation
type UIStepAction ¶
type UIStepAction struct {
Type string `json:"type"`
Parameters map[string]interface{} `json:"parameters"`
}
UIStepAction represents a UI action in an integration step
func (*UIStepAction) GetType ¶
func (usa *UIStepAction) GetType() string
GetType returns the action type
type UITest ¶
type UITest struct {
Name string
URL string
Actions []UIAction
Assertions []UIAssertion
}
UITest represents a UI test case
type UITester ¶
type UITester interface {
Tester
Navigate(url string) error
// Click clicks on an element identified by the selector
Click(selector string) error
// Type types text into an element identified by the selector
Type(selector, text string) error
// GetText retrieves text from an element identified by the selector
GetText(selector string) (string, error)
// WaitForElement waits for an element to be present
WaitForElement(selector string, timeout time.Duration) error
// TakeScreenshot captures a screenshot and returns the file path
TakeScreenshot(filename string) (string, error)
// GetPageSource returns the current page source
GetPageSource() (string, error)
// ExecuteTest executes a UI test and returns the result
ExecuteTest(test *UITest) *TestCaseResult
}
UITester interface defines methods for UI testing capabilities
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
GitCommit string `json:"git_commit"`
BuildDate string `json:"build_date"`
GoVersion string `json:"go_version"`
Platform string `json:"platform"`
}
VersionInfo contains detailed version information
func GetVersionInfo ¶
func GetVersionInfo() *VersionInfo
GetVersionInfo returns detailed version information