This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Purpose Setup integration testing ## Changes - Added integration_test package - Added an integration test - Added helper files to run integration tests on web - Added to README file, how to run integration tests - Added CI file with integration tests that run on push to main/feature branches. ## Checklist - [x] My code follows the style of this project. - [x] The code compiles without warnings. - [x] I have performed a self-review of the changes. - [x] I have documented my code, in particular the intent of the hard-to-understand areas. - [ ] (If necessary) I have updated the CHANGELOG.
- Loading branch information
Showing
9 changed files
with
280 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Integration tests | ||
|
||
on: | ||
# Trigger the workflow on pushes to the main and feature branches. | ||
push: | ||
branches: [main, feature/**] | ||
|
||
# Allows us to run the workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
env: | ||
flutter_version: 3.13.6 | ||
iphone_model: iPhone 8 | ||
android_profile: Nexus 6 | ||
android_api_level: 29 | ||
android_target: google_apis | ||
|
||
jobs: | ||
android-integration-tests: | ||
# It should be most efficient to use the macOS because of hardware acceleration available here. | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.flutter_version }} | ||
channel: 'stable' | ||
cache: true | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '11' | ||
|
||
# Run integration test with android emulator | ||
- name: Run Flutter integration tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
target: ${{ env.android_target }} | ||
api-level: ${{ env.android_api_level }} | ||
arch: x86_64 | ||
profile: ${{ env.android_profile }} | ||
script: flutter test integration_test/ | ||
|
||
iOS-integration-tests: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.flutter_version }} | ||
channel: 'stable' | ||
cache: true | ||
|
||
# Start iOS simulator | ||
- uses: futureware-tech/simulator-action@v3 | ||
with: | ||
model: ${{ env.iphone_model }} | ||
|
||
# Run integration test | ||
- run: flutter test integration_test/ | ||
|
||
web-integration-test: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.flutter_version }} | ||
channel: 'stable' | ||
cache: true | ||
- uses: nanasess/setup-chromedriver@v2 | ||
- run: chromedriver --port=4444 & ./integration_test/run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Integration tests | ||
|
||
on: | ||
# Trigger the workflow on pushes to the main and feature branches. | ||
push: | ||
branches: [main, feature/**] | ||
|
||
# Allows us to run the workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
env: | ||
flutter_version: 3.13.6 | ||
iphone_model: iPhone 8 | ||
android_profile: Nexus 6 | ||
android_api_level: 29 | ||
android_target: google_apis | ||
|
||
jobs: | ||
android-integration-tests: | ||
# It should be most efficient to use the macOS because of hardware acceleration available here. | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.flutter_version }} | ||
channel: 'stable' | ||
cache: true | ||
- uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '11' | ||
|
||
# Run integration test with android emulator | ||
- name: Run Flutter integration tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
target: ${{ env.android_target }} | ||
api-level: ${{ env.android_api_level }} | ||
arch: x86_64 | ||
profile: ${{ env.android_profile }} | ||
script: flutter test integration_test/ | ||
|
||
iOS-integration-tests: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.flutter_version }} | ||
channel: 'stable' | ||
cache: true | ||
|
||
# Start iOS simulator | ||
- uses: futureware-tech/simulator-action@v3 | ||
with: | ||
model: ${{ env.iphone_model }} | ||
|
||
# Run integration test | ||
- run: flutter test integration_test/ | ||
|
||
web-integration-test: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.flutter_version }} | ||
channel: 'stable' | ||
cache: true | ||
- uses: nanasess/setup-chromedriver@v2 | ||
- run: chromedriver --port=4444 & ./integration_test/run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Use HEADER environment variable to run tests with header (as it defaults to running them headerless) | ||
if [[ -z "${HEADER}" ]]; then | ||
DEVICE=web-server | ||
else | ||
DEVICE=chrome | ||
fi | ||
|
||
find integration_test -type f -name '*_test.dart' | while read -r filename; do | ||
[ -e "$filename" ] || continue | ||
flutter drive --driver=integration_test/test_driver.dart --target=$filename -d $DEVICE | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:concordium_wallet/screens/terms_and_conditions/widget.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:concordium_wallet/main.dart' as start; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
testWidgets('Confirming T&C on the initial page brings us to the reset T&C page and resetting accepted T&C brings us back.', (tester) async { | ||
// Load app widget. | ||
start.main(); | ||
|
||
await tester.pumpAndSettle(); | ||
|
||
expect(find.textContaining('Accepted T&C version', findRichText: true), findsNothing); | ||
expect(find.textContaining('Before you begin', findRichText: true), findsOneWidget); | ||
|
||
await tester.tap(find.byType(ToggleAcceptedWidget)); | ||
|
||
await tester.pump(); | ||
|
||
await tester.tap(find.text("Continue", findRichText: true)); | ||
|
||
// Trigger a frame. | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.textContaining('Accepted T&C version', findRichText: true), findsOneWidget); | ||
|
||
await tester.tap(find.text("Reset accepted T&C", findRichText: true)); | ||
|
||
// Trigger a frame. | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.textContaining('Accepted T&C version', findRichText: true), findsNothing); | ||
expect(find.textContaining('Before you begin', findRichText: true), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'package:integration_test/integration_test_driver.dart'; | ||
|
||
Future<void> main() => integrationDriver(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters