-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take screenshot on failure option #534
Comments
Status
Screenshot on failure example (1)Code import 'package:example/main.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
import 'config.dart';
Future<void> main() async {
late PatrolTester tester;
patrolTest(
'takes a screenshot after failed expect',
config: patrolConfig,
nativeAutomation: true,
($) async {
tester = $;
await $.pumpWidgetAndSettle(ExampleApp());
expect('0', '1');
},
);
tearDown(() async {
await tester.host.takeScreenshot(name: 'after_failed_assertion');
});
} Screenshot Screenshot on failure example (2)I like this better. Code import 'package:example/main.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
import 'config.dart';
Future<void> main() async {
patrolTest(
'takes a screenshot after failed expect',
config: patrolConfig,
nativeAutomation: true,
($) async {
addTearDown(() async {
await $.host.takeScreenshot(name: 'after_failed_assertion');
});
await $.pumpWidgetAndSettle(ExampleApp());
await $('Add').tap(); // increments counter by 10
expect($('11'), findsOneWidget);
},
);
} Screenshot |
Update: the below is fixed, see #593 ProblemOops, we've got a serious problem – after an hour of searching, I can't find any way to do reverse port forwarding on physical iOS devices. I've assumed it's not gonna be a problem because we have the $ iproxy 2000 3000 but apparently, This makes it impossible to use any host features (such as taking screenshots, executing scripts, etc.) from withing a test running on a physical iOS device. Android and iOS simulator work very nicely. |
todo: check if we can take screenshot only test failed |
I couldn't find a way to execute code only if a particular test case failed. |
We tried to refine this today, but realized we don't know what the requirements are. |
It's worth noting that there is native support for this with |
Let's consider an option that defaults to taking screenshots after any failures.
The text was updated successfully, but these errors were encountered: