Background
TestSemantics is used to quickly check that dumping a semantics tree produces some exact string. This is easy to set up, but is often a cause of unhelpful failures. For example, you may have made a small change to the widgets returned from a build method before only to be greeted by a large wall of text about how the semantics no longer matches.
How to test semantics instead
Instead, find the exact semantics node that is relevant to the given test using tester.semantics.find.
Migrating
This came up in #183790 (comment), where it was decided that we would duplicate TestSemantics in the new material_ui package instead of exposing it publicly in flutter_test, in order to avoid encouraging other people to use it. We should migrate all usages across flutter/flutter and material_ui to use the recommendation above, and then remove both instances of TestSemantics.
List of locations to migrate
Test files that use TestSemantics
Background
TestSemantics is used to quickly check that dumping a semantics tree produces some exact string. This is easy to set up, but is often a cause of unhelpful failures. For example, you may have made a small change to the widgets returned from a
buildmethod before only to be greeted by a large wall of text about how the semantics no longer matches.How to test semantics instead
Instead, find the exact semantics node that is relevant to the given test using
tester.semantics.find.Migrating
This came up in #183790 (comment), where it was decided that we would duplicate TestSemantics in the new material_ui package instead of exposing it publicly in flutter_test, in order to avoid encouraging other people to use it. We should migrate all usages across flutter/flutter and material_ui to use the recommendation above, and then remove both instances of TestSemantics.
List of locations to migrate
Test files that use TestSemantics