runAllTests method

Future<AutotestSummary> runAllTests({
  1. dynamic onProgress(
    1. String
    )?,
})

Run all autotest suite and return summary

Implementation

Future<AutotestSummary> runAllTests({
  Function(String)? onProgress,
}) async {
  if (_isRunning) {
    throw StateError('Autotest is already running');
  }

  _isRunning = true;
  _results.clear();
  _onProgress = onProgress;

  _log('🚀 OBSLY AUTOTEST SUITE STARTING');
  _log(
      'Platform: ${kIsWeb ? 'WEB' : 'NATIVE (${Platform.operatingSystem})'}');
  _log('======================================');

  try {
    // Test 1: SDK Initialization
    await _testSDKInitialization();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 2: HTTP Interception
    await _testHTTPInterception();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 2.5: HTTP Auto-Repair (Web Only)
    if (kIsWeb) {
      await _testHTTPAutoRepair();
      await Future.delayed(const Duration(milliseconds: 500));
    }

    // Test 3: Lifecycle Event Capture
    await _testLifecycleEventCapture();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 4: UI Event Capture
    await _testUIEventCapture();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 5: Navigation Integration
    await _testNavigationIntegration();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 6: Console Integration
    await _testConsoleIntegration();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 7: Crash Integration
    await _testCrashIntegration();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 8: Event Storage
    await _testEventStorage();
    await Future.delayed(const Duration(milliseconds: 500));

    // Test 9: Debug Tools
    await _testDebugTools();

    // Return final results
    return _generateSummary();
  } catch (e, stackTrace) {
    _addResult(AutotestResult(
      testName: 'CRITICAL_ERROR',
      success: false,
      message: 'Autotest crashed: $e',
      details: stackTrace.toString(),
    ));

    return AutotestSummary(
      successful: 0,
      failed: _results.length,
      total: _results.length,
      successRate: 0.0,
      passed: false,
      results: List.from(_results),
    );
  } finally {
    _isRunning = false;
    _onProgress = null;
  }
}