Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ matrix:
- platform-tools
- build-tools-28.0.3
- android-28
- android-29
- extra-android-m2repository
- extra-google-m2repository
- extra-google-android-support
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

# Publish
1. Bump up versions in these files: *ios/testfairy.podspec*, *android/build.gradle*, *pubspec.yaml*, *example/pubspec.yaml*, *CHANGELOG.md*.
2. Run `dartfmt -w lib example/lib example/test example/test_driver`
2. Run `dartfmt -w lib example/lib example/test example/test_driver example/integration_test`
3. Publish to pub.
4 changes: 3 additions & 1 deletion android-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set -e

# prepare
yes | sdkmanager "platforms;android-28"
yes | sdkmanager "platforms;android-29"
wget https://services.gradle.org/distributions/gradle-3.5-bin.zip
unzip -qq gradle-3.5-bin.zip
export GRADLE_HOME=$PWD/gradle-3.5
Expand All @@ -19,4 +20,5 @@ cd ..
../flutter/bin/flutter analyze $PWD/lib
#../flutter/bin/flutter analyze $PWD/example/lib
#../flutter/bin/flutter analyze $PWD/example/test
#../flutter/bin/flutter analyze $PWD/example/test_driver
#../flutter/bin/flutter analyze $PWD/example/test_driver
#../flutter/bin/flutter analyze $PWD/example/integration_test
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public void onMethodCall(MethodCall call, Result result) {
case "hideWidget":
hideWidget();
result.success(null);
break;
default:
result.notImplemented();
break;
Expand Down
101 changes: 101 additions & 0 deletions example/integration_test/app_integration_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

// ignore: avoid_relative_lib_imports
import '../lib/main.dart' as app;

void main() {
group('Testfairy Plugin Tests', () {
Finder findByValueKey(String keyName) {
final ValueKey<String> key = ValueKey<String>(keyName);
return find.byKey(key);
}

final Finder errorTextFinder = findByValueKey('errorMessage');
final Finder testingFinder = findByValueKey('testing');
final Finder scrollerFinder = findByValueKey('scroller');

setUpAll(() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
});

// Helper test builder:
// 1. Scrolls and finds a button that runs a test case.
// 2. Before waiting the test to complete, allows you to inject additional logic.
// 3. Waits for test completion.
// 4. Asserts failure if error is found.
void testfairyTest(
String testName, Finder testButtonFinder, Function testCaseFunction,
{bool scroll = true}) {
testWidgets(testName, (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();

if (scroll) {
await tester.scrollUntilVisible(testButtonFinder, 40,
scrollable: scrollerFinder,
maxScrolls: 100,
duration: const Duration(seconds: 10));
}

await tester.tap(testButtonFinder);

await testCaseFunction();

bool testingFinderStillFinds = tester.any(testingFinder);
for (int i = 0; i < 10; i++) {
testingFinderStillFinds = tester.any(testingFinder);

if (!testingFinderStillFinds) {
break;
}

await Future<void>.delayed(const Duration(seconds: 1));
}

expect(testingFinderStillFinds, false);

tester.element(errorTextFinder);

final String x =
(errorTextFinder.evaluate().single.widget as Text).data ??
'No error yet';
print('$testName: $x');

expect(x, 'No error yet.');
});
}

// Helper test builder:
// 1. Scrolls and finds a button that runs a test case.
// 2. Waits for test completion.
// 3. Asserts failure if error is found.
void testfairyTestSimple(String testName, Finder testButtonFinder,
{bool scroll = true}) {
testfairyTest(testName, testButtonFinder, () async {}, scroll: scroll);
}

// Test cases (implement a button that starts the test on ui, find and tap it with a finder)
testfairyTestSimple('Lifecycle Test', findByValueKey('lifecycleTests'),
scroll: false);
testfairyTestSimple(
'Server Endpoint Test', findByValueKey('serverEndpointTest'));
testfairyTestSimple('Feedback Tests', findByValueKey('feedbackTests'));
testfairyTestSimple(
'Feedback Shake Test', findByValueKey('feedbackShakeTest'));
testfairyTestSimple('Version Test', findByValueKey('versionTest'));
testfairyTestSimple('Session Url Test', findByValueKey('sessionUrlTest'));
testfairyTestSimple(
'Add Checkpoint Test', findByValueKey('addCheckpointTest'));
testfairyTestSimple('Add Event Test', findByValueKey('addEventTest'));
testfairyTestSimple('Identity Tests', findByValueKey('identityTests'));
testfairyTestSimple('Log Tests', findByValueKey('logTests'));
testfairyTestSimple(
'Developer Options Tests', findByValueKey('developerOptionsTests'));
testfairyTestSimple('Network Log Tests', findByValueKey('networkLogTests'));
testfairyTestSimple(
'Disable Auto Update Tests', findByValueKey('disableAutoUpdateTests'));
// testfairyTestSimple('Feedback Options Tests', findByValueKey('feedbackOptionsTests'));
});
}
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {

// Call `await TestFairy.begin()` or any other setup code here.
// await TestFairy.setMaxSessionLength(60);
await TestFairy.begin(APP_TOKEN);
// await TestFairy.begin(APP_TOKEN);
// await TestFairy.installFeedbackHandler(APP_TOKEN);

// runApp(TestfairyExampleApp());
Expand Down
5 changes: 3 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: 'none'
version: 2.0.7

environment:
sdk: ">=2.10.0 <3.0.0"
sdk: ">=2.12.0-31.0.dev <3.0.0"
flutter: ">=1.22.0 <2.0.0"

dependencies:
Expand All @@ -13,12 +13,13 @@ dependencies:

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
cupertino_icons: ^1.0.2

# These exist for testing and should never be included by TestFairy SDK
http: any

dev_dependencies:
integration_test: ^1.0.0
flutter_test:
sdk: flutter

Expand Down
2 changes: 1 addition & 1 deletion example/test_driver/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void main() {

if (scroll) {
await driver.scrollUntilVisible(scrollerFinder, testButtonFinder,
alignment: 0.5, timeout: const Duration(seconds: 10));
alignment: 0.5, timeout: const Duration(seconds: 10), dxScroll: 10, dyScroll: 10);
}

await driver.tap(testButtonFinder, timeout: timeout);
Expand Down
1 change: 1 addition & 0 deletions ios-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ cd ..
#../flutter/bin/flutter analyze $PWD/example/lib
#../flutter/bin/flutter analyze $PWD/example/test
#../flutter/bin/flutter analyze $PWD/example/test_driver
#../flutter/bin/flutter analyze $PWD/example/integration_test


2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2.0.7
homepage: https://testfairy.com

environment:
sdk: ">=2.10.0 <3.0.0"
sdk: ">=2.12.0-31.0.dev <3.0.0"
flutter: ">=1.22.0 <2.0.0"

dependencies:
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions test-with-integration-android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

pushd example
pushd android

# flutter build generates files in android/ for building the app
flutter build apk --enable-experiment=non-nullable --no-sound-null-safety
./gradlew app:assembleAndroidTest
./gradlew app:assembleDebug -Ptarget=integration_test/app_integration_test.dart

popd
popd