LeakTesting class

leak_tracker settings for tests.

Set LeakTesting.settings, to change default leak tracking settings for tests. Set it for package or folder in flutter_test_config.dart and for a test file in setUpAll.

If you update the settings for a group, remember the original value to a local variable and restore it in tearDownAll for the group.

Use methods that return adjusted LeakTesting.settings to customize default for an individual test:

testWidgets(
    'initialTimerDuration falls within limit',
    leakTracking: LeakTesting.settings.withIgnoredAll(),
    (WidgetTester tester) async {
      ...

If LeakTesting.settings are updated during a test run, the new value will be used for the next test.

Annotations

Properties

baselining MemoryBaselining
Settings to measure the test's memory footprint.
final
hashCode int
The hash code for this object.
no setteroverride
ignore bool
If true, leak tracking is paused.
final
ignoredLeaks IgnoredLeaks
Leaks to ignore.
final
leakDiagnosticConfig LeakDiagnosticConfig
Defines which diagnostics information to collect.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({IgnoredLeaks? ignoredLeaks, LeakDiagnosticConfig? leakDiagnosticConfig, bool? ignore, MemoryBaselining? baselining}) LeakTesting
Creates a copy of this object with the given fields replaced with the new values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withCreationStackTrace() LeakTesting
Copies with enabled collection of creation stack trace.
withDisposalStackTrace() LeakTesting
Copies with enabled collection of disposal stack trace.
withIgnored({Map<String, int?> notGCed = const {}, bool allNotGCed = false, Map<String, int?> notDisposed = const {}, bool allNotDisposed = false, List<String> classes = const [], bool createdByTestHelpers = false, List<RegExp> testHelperExceptions = const []}) LeakTesting
Returns copy of settings with extended ignore lists.
withIgnoredAll() LeakTesting
Copies with ignore set to true.
withRetainingPath() LeakTesting
Creates copy of settings, that collects the retaining path for not GCed objects.
withTracked({List<String> experimentalNotGCed = const [], List<String> notDisposed = const [], List<String> classes = const [], bool experimentalAllNotGCed = false, bool allNotDisposed = false, bool createdByTestHelpers = false}) LeakTesting
Returns copy of settings with reduced ignore lists.
withTrackedAll() LeakTesting
Copies with ignore set to false.

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

collectedLeaksReporter LeaksCallback
Handler for memory leaks found in tests.
getter/setter pair
enabled bool
If true, leak tracking is enabled.
no setter
settings LeakTesting
Current configuration for leak tracking.
getter/setter pair

Static Methods

enable() → void
Invoke in flutter_test_config.dart to enable leak tracking.