44
55import 'dart:async' ;
66
7- import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart' ;
87import 'package:meta/meta.dart' ;
98import 'package:test_api/scaffolding.dart' show Timeout;
109import 'package:test_api/src/backend/declarer.dart' ; // ignore: implementation_imports
@@ -164,7 +163,6 @@ void test(
164163 Map <String , dynamic >? onPlatform,
165164 int ? retry,
166165}) {
167- _configureTearDownForTestFile ();
168166 _declarer.test (
169167 description.toString (),
170168 body,
@@ -188,7 +186,6 @@ void test(
188186/// of running the group's tests.
189187@isTestGroup
190188void group (Object description, void Function () body, { dynamic skip, int ? retry }) {
191- _configureTearDownForTestFile ();
192189 _declarer.group (description.toString (), body, skip: skip, retry: retry);
193190}
194191
@@ -204,7 +201,6 @@ void group(Object description, void Function() body, { dynamic skip, int? retry
204201/// Each callback at the top level or in a given group will be run in the order
205202/// they were declared.
206203void setUp (dynamic Function () body) {
207- _configureTearDownForTestFile ();
208204 _declarer.setUp (body);
209205}
210206
@@ -222,7 +218,6 @@ void setUp(dynamic Function() body) {
222218///
223219/// See also [addTearDown] , which adds tear-downs to a running test.
224220void tearDown (dynamic Function () body) {
225- _configureTearDownForTestFile ();
226221 _declarer.tearDown (body);
227222}
228223
@@ -240,7 +235,6 @@ void tearDown(dynamic Function() body) {
240235/// prefer [setUp] , and only use [setUpAll] if the callback is prohibitively
241236/// slow.
242237void setUpAll (dynamic Function () body) {
243- _configureTearDownForTestFile ();
244238 _declarer.setUpAll (body);
245239}
246240
@@ -256,27 +250,9 @@ void setUpAll(dynamic Function() body) {
256250/// prefer [tearDown] , and only use [tearDownAll] if the callback is
257251/// prohibitively slow.
258252void tearDownAll (dynamic Function () body) {
259- _configureTearDownForTestFile ();
260253 _declarer.tearDownAll (body);
261254}
262255
263- bool _isTearDownForTestFileConfigured = false ;
264- /// Configures `tearDownAll` after all user defined `tearDownAll` in the test file.
265- ///
266- /// This function should be invoked in all functions, that may be invoked by user in the test file,
267- /// to be invoked before any other `tearDownAll` .
268- void _configureTearDownForTestFile () {
269- if (_isTearDownForTestFileConfigured) {
270- return ;
271- }
272- _declarer.tearDownAll (_tearDownForTestFile);
273- _isTearDownForTestFileConfigured = true ;
274- }
275-
276- /// Tear down that should happen after all user defined tear down.
277- Future <void > _tearDownForTestFile () async {
278- await maybeTearDownLeakTrackingForAll ();
279- }
280256
281257/// A reporter that prints each test on its own line.
282258///
0 commit comments