lum_splash_video/test
JohnE fec03326cc MOD: scale of video wired in correctly 2026-01-25 01:53:59 -08:00
..
README.md NEW: first working splash video alpha 2026-01-24 19:42:44 -08:00
splash_video_controller_test.dart NEW: first working splash video alpha 2026-01-24 19:42:44 -08:00
splash_video_page_test.dart MOD: renamed to SplashVideo which makes more sense 2026-01-24 22:17:30 -08:00
utils_test.dart NEW: first working splash video alpha 2026-01-24 19:42:44 -08:00
video_config_test.dart MOD: scale of video wired in correctly 2026-01-25 01:53:59 -08:00
video_source_test.dart NEW: first working splash video alpha 2026-01-24 19:42:44 -08:00

README.md

Testing Guide for splash_video

This package includes comprehensive unit and integration tests to ensure reliability and correctness.

Test Structure

Unit Tests (/test)

Unit tests verify individual components in isolation:

  • video_source_test.dart - Tests for all Source types (Asset, Network, DeviceFile, Bytes)
  • splash_video_controller_test.dart - Tests for controller lifecycle and operations
  • video_config_test.dart - Tests for VideoConfig and VisibilityEnum
  • utils_test.dart - Tests for utility functions, exceptions, and typedefs
  • splash_video_page_test.dart - Widget tests for SplashVideoPage

Integration Tests (/example/integration_test)

Integration tests verify end-to-end functionality:

  • plugin_integration_test.dart - Full integration tests including:
    • Configuration validation
    • Error handling
    • Overlay rendering
    • Controller integration
    • Source type handling
    • VideoConfig integration

Running Tests

Run All Unit Tests

flutter test

Run Specific Test File

flutter test test/video_source_test.dart

Run Tests with Coverage

flutter test --coverage

Run Integration Tests

cd example
flutter test integration_test/plugin_integration_test.dart

Run Integration Tests on Device

cd example
flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/plugin_integration_test.dart

Test Coverage

The test suite covers:

  • All Source types and validation
  • SplashVideoController lifecycle
  • VideoConfig options
  • Error handling and callbacks
  • Overlay rendering
  • Navigation validation
  • Looping behavior
  • Widget composition

Writing New Tests

Unit Test Template

import 'package:flutter_test/flutter_test.dart';
import 'package:splash_video/splash_video.dart';

void main() {
  group('Feature Name', () {
    test('should do something', () {
      // Arrange
      final input = ...;
      
      // Act
      final result = ...;
      
      // Assert
      expect(result, equals(expected));
    });
  });
}

Widget Test Template

testWidgets('widget should render', (WidgetTester tester) async {
  await tester.pumpWidget(
    MaterialApp(
      home: YourWidget(),
    ),
  );
  
  expect(find.byType(YourWidget), findsOneWidget);
});

Integration Test Template

testWidgets('integration scenario', (WidgetTester tester) async {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  
  await tester.pumpWidget(MyApp());
  await tester.pumpAndSettle();
  
  // Interact with the app
  await tester.tap(find.byIcon(Icons.add));
  await tester.pumpAndSettle();
  
  // Verify results
  expect(find.text('Result'), findsOneWidget);
});

CI/CD Integration

GitHub Actions

name: Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: subosito/flutter-action@v2
      - run: flutter pub get
      - run: flutter test --coverage
      - run: cd example && flutter test integration_test

Troubleshooting

MediaKit Initialization

Some tests require MediaKit initialization. This is handled automatically in test files:

setUpAll(() {
  MediaKit.ensureInitialized();
});

Video Assets

Integration tests may require actual video assets in example/assets/. For tests without real videos, use error handling:

onVideoError: (_) {}, // Suppress errors in tests

Platform Differences

Some media_kit features are platform-specific. Tests should be designed to handle platform variations gracefully.

Test Best Practices

  1. Keep tests isolated - Each test should be independent
  2. Use descriptive names - Test names should explain what they verify
  3. Test edge cases - Include boundary conditions and error scenarios
  4. Mock external dependencies - Use test doubles when appropriate
  5. Clean up resources - Dispose controllers and players in tearDown
  6. Use test groups - Organize related tests together
  7. Verify error handling - Test both success and failure paths

Known Limitations

  • Video playback tests require platform-specific media support
  • Some tests may need real video files to fully verify behavior
  • Network tests depend on connectivity (should use mocks for CI/CD)
  • Player initialization timing can vary across platforms