Thanks to visit codestin.com
Credit goes to github.com

Skip to content

expect() in semantic test producing unhelpful output #110598

Closed
@pdblasi-google

Description

@pdblasi-google

Originally reported @ b/243693776

When writing a semantic test (that is expected to fail), I see an unhelpful error. Previously, the error showed the diff of the expected properties and the actual ones, but I believe an exception is being thrown while calculating this diff.

Steps to Reproduce

  1. Create a test using matchesSemantics or containsSemantics that is expected to fail
  2. Run the test

Expected results: Test fails with error messaging that compares expected and actual output with no errors

Actual results: Test fails with error messaging containing errors

Code sample
      expect(
        tester.getSemantics(find.bySemanticsLabel('title')),
        matchesSemantics(
          hasTapAction: true,
          hasEnabledState: true,
          isEnabled: true,
          hasToggledState: true,
          isToggled: true,
          isFocusable: true,
          isSelected: true,
        ),
      );
Logs
The following TestFailure was thrown running a test:
Expected: has semantics with actions:
[SemanticsAction:SemanticsAction.tap] without actions: [
            SemanticsAction:SemanticsAction.longPress,
            SemanticsAction:SemanticsAction.scrollLeft,
            SemanticsAction:SemanticsAction.scrollRight,
            SemanticsAction:SemanticsAction.scrollUp,
            SemanticsAction:SemanticsAction.scrollDown,
            SemanticsAction:SemanticsAction.increase,
            SemanticsAction:SemanticsAction.decrease,
            SemanticsAction:SemanticsAction.showOnScreen,
            SemanticsAction:SemanticsAction.moveCursorForwardByCharacter,
            SemanticsAction:SemanticsAction.moveCursorBackwardByCharacter,
            SemanticsAction:SemanticsAction.setSelection,
            SemanticsAction:SemanticsAction.copy,
            SemanticsAction:SemanticsAction.cut,
            SemanticsAction:SemanticsAction.paste,
            SemanticsAction:SemanticsAction.didGainAccessibilityFocus,
            SemanticsAction:SemanticsAction.didLoseAccessibilityFocus,
            SemanticsAction:SemanticsAction.dismiss,
            SemanticsAction:SemanticsAction.moveCursorForwardByWord,
            SemanticsAction:SemanticsAction.moveCursorBackwardByWord,
            SemanticsAction:SemanticsAction.setText
          ] with flags: [
            SemanticsFlag:SemanticsFlag.isButton,
            SemanticsFlag:SemanticsFlag.isFocusable,
            SemanticsFlag:SemanticsFlag.hasEnabledState,
            SemanticsFlag:SemanticsFlag.isEnabled,
            SemanticsFlag:SemanticsFlag.isInMutuallyExclusiveGroup
          ] without flags: [
            SemanticsFlag:SemanticsFlag.hasCheckedState,
            SemanticsFlag:SemanticsFlag.isChecked,
            SemanticsFlag:SemanticsFlag.isSelected,
            SemanticsFlag:SemanticsFlag.isSlider,
            SemanticsFlag:SemanticsFlag.isKeyboardKey,
            SemanticsFlag:SemanticsFlag.isLink,
            SemanticsFlag:SemanticsFlag.isTextField,
            SemanticsFlag:SemanticsFlag.isReadOnly,
            SemanticsFlag:SemanticsFlag.isFocused,
            SemanticsFlag:SemanticsFlag.isHeader,
            SemanticsFlag:SemanticsFlag.isObscured,
            SemanticsFlag:SemanticsFlag.isMultiline,
            SemanticsFlag:SemanticsFlag.namesRoute,
            SemanticsFlag:SemanticsFlag.scopesRoute,
            SemanticsFlag:SemanticsFlag.isHidden,
            SemanticsFlag:SemanticsFlag.isImage,
            SemanticsFlag:SemanticsFlag.isLiveRegion,
            SemanticsFlag:SemanticsFlag.hasToggledState,
            SemanticsFlag:SemanticsFlag.isToggled,
            SemanticsFlag:SemanticsFlag.hasImplicitScrolling
          ]
  Actual: SemanticsNode:<SemanticsNode#10(Rect.fromLTRB(0.0, 0.0,
103.0, 64.0), actions: [tap], flags: [isButton, hasEnabledState,
isEnabled, isFocusable], label: "title", textDirection:
ltr)>
   Which: null
'package:flutter/src/foundation/diagnostics.dart': Failed
assertion: line 3057 pos 5: 'indexOfDot != -1 && indexOfDot <
description.length - 1': The provided object "8" is not an enum.
at #0      _AssertionError._doThrowNew
(dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew
(dart:core-patch/errors_patch.dart:40:5)
#2      describeEnum
(package:flutter/src/foundation/diagnostics.dart:3057:5)
#3      _MatchesSemanticsData.matches
(package:flutter_test/src/matchers.dart:2483:45)
#4      _expect (package:test_api/src/expect/expect.dart:123:30)
#5      expect (package:test_api/src/expect/expect.dart:46:3)
#6      expect
(package:flutter_test/src/widget_tester.dart:460:16)
#7      main.<anonymous closure>.<anonymous closure>
...

Metadata

Metadata

Labels

a: tests"flutter test", flutter_test, or one of our testscustomer: googleVarious Google teams

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions