-
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.
- Loading branch information
1 parent
652cd51
commit d01f81a
Showing
1 changed file
with
44 additions
and
0 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,44 @@ | ||
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 = 'groupA testA'; | ||
|
||
String get currentTest => Invoker.current!.fullCurrentTestName(); | ||
|
||
void main() { | ||
patrolSetUp(() { | ||
print('setting up before $currentTest'); | ||
}); | ||
|
||
patrolTearDown(() { | ||
print('tearing down after $currentTest'); | ||
}); | ||
|
||
group('groupA', () { | ||
test('testA', () {}); | ||
test('testB', () {}); | ||
test('testC', () {}); | ||
}); | ||
} | ||
|
||
void patrolSetUp(dynamic Function() body) { | ||
setUp(() { | ||
final currentTest = Invoker.current!.fullCurrentTestName(); | ||
|
||
if (currentTest == requestedTest) { | ||
body(); | ||
} | ||
}); | ||
} | ||
|
||
void patrolTearDown(dynamic Function() body) { | ||
tearDown(() { | ||
final currentTest = Invoker.current!.fullCurrentTestName(); | ||
|
||
if (currentTest == requestedTest) { | ||
body(); | ||
} | ||
}); | ||
} |