hot_reload_errors_test.dart 1.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:file/file.dart';

import '../src/common.dart';
import 'test_data/hot_reload_const_project.dart';
import 'test_driver.dart';
import 'test_utils.dart';

void main() {
13
  late Directory tempDir;
14
  final HotReloadConstProject project = HotReloadConstProject();
15
  late FlutterRunTestDriver flutter;
16 17 18 19 20 21 22 23

  setUp(() async {
    tempDir = createResolvedTempDirectorySync('hot_reload_test.');
    await project.setUpIn(tempDir);
    flutter = FlutterRunTestDriver(tempDir);
  });

  tearDown(() async {
24
    await flutter.stop();
25 26 27 28 29 30 31
    tryToDelete(tempDir);
  });

  testWithoutContext('hot reload displays a formatted error message when removing a field from a const class', () async {
    await flutter.run();
    project.removeFieldFromConstClass();

32
    expect(flutter.hotReload(), throwsA(isA<Exception>().having((Exception e) => e.toString(), 'message', contains('Try performing a hot restart instead.'))));
33 34
  });
}