-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP (try out
currentGroupFullName
approach)
- Loading branch information
1 parent
0e9b69d
commit 40bd9a4
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/patrol/example/integration_test/internal/callbacks_all_test.dart
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,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:patrol/src/extensions.dart'; | ||
// ignore: depend_on_referenced_packages | ||
import 'package:test_api/src/backend/invoker.dart'; | ||
|
||
import '../common.dart'; | ||
|
||
String get currentTest => Invoker.current!.fullCurrentTestName(); | ||
|
||
void _print(String text) => print('PATROL_DEBUG: $text'); | ||
|
||
void main() { | ||
patrolSetUpAll(() async { | ||
await Future<void>.delayed(Duration(seconds: 1)); | ||
_print('setting up all before $currentTest'); | ||
}); | ||
|
||
patrolTest('testA', nativeAutomation: true, _body); | ||
patrolTest('testB', nativeAutomation: true, _body); | ||
patrolTest('testC', nativeAutomation: true, _body); | ||
} | ||
|
||
Future<void> _body(PatrolTester $) async { | ||
final testName = Invoker.current!.fullCurrentTestName(); | ||
_print('test body: name=$testName'); | ||
|
||
await createApp($); | ||
|
||
await $(FloatingActionButton).tap(); | ||
expect($(#counterText).text, '1'); | ||
|
||
await $(#textField).enterText(testName); | ||
|
||
await $.pumpAndSettle(duration: Duration(seconds: 2)); | ||
} |
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,45 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:patrol/src/extensions.dart'; | ||
// ignore: depend_on_referenced_packages | ||
import 'package:test_api/src/backend/invoker.dart'; | ||
|
||
const String requestedTest = 'testA'; | ||
|
||
String get currentTest => Invoker.current!.fullCurrentTestName(); | ||
|
||
void main() { | ||
group('alpha', () { | ||
setUpAll(() { | ||
final groupName = Invoker.current!.liveTest.groups.last.name; | ||
final individualName = Invoker.current!.liveTest.individualName; | ||
print( | ||
'setUpAll: parentGroupName=$groupName, individualName=$individualName', | ||
); | ||
}); | ||
|
||
setUp(() { | ||
final groupName = Invoker.current!.liveTest.groups.last.name; | ||
final individualName = Invoker.current!.liveTest.individualName; | ||
print( | ||
'setUpAll: parentGroupName=$groupName, individualName=$individualName', | ||
); | ||
}); | ||
|
||
patrolTest('testA', _body); | ||
patrolTest('testB', _body); | ||
patrolTest('testC', _body); | ||
}); | ||
} | ||
|
||
Future<void> _body() async => print(Invoker.current!.fullCurrentTestName()); | ||
|
||
void patrolTest(String name, Future<void> Function() body) { | ||
test(name, () async { | ||
final currentTest = Invoker.current!.fullCurrentTestName(); | ||
|
||
if (currentTest == requestedTest) { | ||
print('Requested test $currentTest, will execute it'); | ||
await body(); | ||
} | ||
}); | ||
} |
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