Skip to content

A test can change ErrorWidget.builder without resetting it. #30897

@dnfield

Description

@dnfield

The following tests will pass individually but fail when run in this order:

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('Set builder', () async {
    const Text text = Text('asdf');
    ErrorWidget.builder = (FlutterErrorDetails details) => text;
    expect(ErrorWidget.builder(FlutterErrorDetails()), text);
  });

  test('No set builder', () async {
    expect(ErrorWidget.builder(FlutterErrorDetails()), isInstanceOf<ErrorWidget>());
  });
}

We should be checking that no test (or at least no testWidgets test) modifies this without resetting it, like with other static/top level setters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions