ci: e2e tests (#9)

This commit is contained in:
Felix Angelov 2022-02-28 12:02:46 -06:00 committed by GitHub
parent 568ff904a3
commit 229c2755d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 170 additions and 2 deletions

View File

@ -19,3 +19,137 @@ jobs:
flutter_channel: stable flutter_channel: stable
flutter_version: 2.10.1 flutter_version: 2.10.1
working_directory: src/my_plugin working_directory: src/my_plugin
linux:
runs-on: ubuntu-18.04
defaults:
run:
working-directory: src/my_plugin/example
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev liblzma-dev
- name: Enable desktop support
run: flutter config --enable-linux-desktop
- name: Flutter Doctor
run: flutter doctor -v
- name: Integration Tests
run: xvfb-run flutter test integration_test -d linux
windows:
runs-on: windows-2019
defaults:
run:
working-directory: src/my_plugin/example
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- name: Enable desktop support
run: flutter config --enable-windows-desktop
- name: Flutter Doctor
run: flutter doctor -v
- name: Integration Tests
run: flutter test integration_test -d windows
macos:
runs-on: macos-10.15
defaults:
run:
working-directory: src/my_plugin/example
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- name: Enable desktop support
run: flutter config --enable-macos-desktop
- name: Flutter Doctor
run: flutter doctor -v
- name: Integration Tests
run: flutter test integration_test -d macos
ios:
runs-on: macos-10.15
defaults:
run:
working-directory: src/my_plugin/example
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- name: Flutter Doctor
run: flutter doctor -v
- name: Start Simulator
run: open -a Simulator.app
- name: Integration Tests
run: flutter test integration_test -d iPhone
android:
runs-on: macos-10.15
defaults:
run:
working-directory: src/my_plugin/example
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: "11"
- uses: subosito/flutter-action@v2
- name: Flutter Doctor
run: flutter doctor -v
- name: AVD Cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
- name: Cache AVD Snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Integration Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: flutter test integration_test
working-directory: src/my_plugin/example

View File

@ -0,0 +1,30 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:my_plugin_example/main.dart' as app;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('E2E', () {
testWidgets('getPlatformName', (tester) async {
app.main();
await tester.pumpAndSettle();
await tester.tap(find.text('Get Platform Name'));
await tester.pumpAndSettle();
final expected = expectedPlatformName();
await tester.ensureVisible(find.text('Platform Name: $expected'));
});
});
}
String expectedPlatformName() {
if (Platform.isAndroid) return 'Android';
if (Platform.isIOS) return 'iOS';
if (Platform.isLinux) return 'Linux';
if (Platform.isMacOS) return 'MacOS';
if (Platform.isWindows) return 'Windows';
throw UnsupportedError('Unsupported platform ${Platform.operatingSystem}');
}

View File

@ -19,6 +19,10 @@ dependencies:
path: ../ path: ../
dev_dependencies: dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
very_good_analysis: ^2.4.0 very_good_analysis: ^2.4.0
flutter: flutter: