flutter/packages/flutter_test/test/test_config/config_test_utils.dart
Todd Volkert 28c1973340
Add support for flutter_test_config.dart (#17141)
This enables support for a `flutter_test_config.dart` configuration file,
which will be discovered and handed the responsibility of running the
test file (thus allowing it to run pre-test setup on a project level).

https://github.com/flutter/flutter/issues/16859
2018-05-01 12:36:22 -07:00

28 lines
851 B
Dart

// Copyright 2018 The Chromium 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 'dart:async';
import 'package:flutter_test/flutter_test.dart';
void testConfig(
String description,
String expectedStringValue, {
Map<Type, dynamic> otherExpectedValues: const <Type, dynamic>{int: isNull},
}) {
final String actualStringValue = Zone.current[String];
final Map<Type, dynamic> otherActualValues = otherExpectedValues.map<Type, dynamic>(
(Type key, dynamic value) {
return new MapEntry<Type, dynamic>(key, Zone.current[key]);
},
);
test(description, () {
expect(actualStringValue, expectedStringValue);
for (Type key in otherExpectedValues.keys) {
expect(otherActualValues[key], otherExpectedValues[key]);
}
});
}