Closed eikebartels closed 1 year ago
Hey 👋
Thank you!
If you plan to use bdd_widget_test
, you will not be able to add additional parameters to the test method, but you can change the type for the parameter. I would recommend you define a new type:
typedef WidgetTesterWithPatrolCallback = Future<void> Function(
({PatrolFinder $, WidgetTester widgetTester}));
And then use it in your new test method:
void testWidgetsWithPatrol(
String description,
WidgetTesterWithPatrolCallback tester,
...
That would allow you to use the new method like that:
testWidgetsWithPatrol('''Scaffold screenshot''', (tester) async {
await tester.$.pumpWidgetAndSettle(
MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('appx')),
backgroundColor: Colors.blue,
),
),
);
expect(tester.$('app'), findsOneWidget);
await tester.$.native.pressHome();
}, tags: ['patrol']);
Just out of my curiosity, why you needed to create this test method and not use regular patrolTest
?
Hey @olexale thanks for your answer.
The idea was to auto create the method though @testMethodName
.
That's clear, you may put testWidgetsWithPatrol
into testMethodName
, and bdd_widget_test
will put the new name for you. I was wondering, why not put patrolTest
into testMethodName
? What benefits do you expect from having testWidgetsWithPatrol
?
Thats a valid point. My intention was to align the method signature
Hello everyone,
first of all thank you for this awesome package.
I'm trying to add a custom test method in replacement of
testWidgets
. This new method has a function callback with 2 parameters instead of one. What is the best way to approach this, do you have any idea?Here is my example code: