Using runZoned to remove test pollution (#54)
* Using runZoned to remove test pollution
* Added comments for runZoned
diff --git a/test/naughty_test.dart b/test/naughty_test.dart
index 6e4e64b..8f3a359 100644
--- a/test/naughty_test.dart
+++ b/test/naughty_test.dart
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import 'dart:async';
+
import 'package:test/test.dart';
import 'package:yaml_edit/yaml_edit.dart';
@@ -22,10 +24,17 @@
test('expect string $string', () {
final doc = YamlEditor('');
- expect(() => doc.update([], string), returnsNormally);
- final value = doc.parseAt([]).value;
- expect(value, isA<String>());
- expect(value, equals(string));
+ /// Using [runZoned] to hide `package:yaml`'s warnings.
+ /// Test failures and errors will still be shown.
+ runZoned(() {
+ expect(() => doc.update([], string), returnsNormally);
+ final value = doc.parseAt([]).value;
+ expect(value, isA<String>());
+ expect(value, equals(string));
+ },
+ zoneSpecification: ZoneSpecification(
+ print: (Zone self, ZoneDelegate parent, Zone zone,
+ String message) {}));
});
}
}
diff --git a/test/fuzz_test.dart b/test/random_test.dart
similarity index 94%
rename from test/fuzz_test.dart
rename to test/random_test.dart
index 1d35a15..42c190d 100644
--- a/test/fuzz_test.dart
+++ b/test/random_test.dart
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import 'dart:async';
import 'dart:math';
import 'package:yaml_edit/yaml_edit.dart';
@@ -35,7 +36,7 @@
const modificationsPerRound = 1000;
for (var i = 0; i < roundsOfTesting; i++) {
- test('fuzz test $i', () {
+ test('testing with randomly generated modifications: test $i', () {
final editor = YamlEditor('''
name: yaml_edit
description: A library for YAML manipulation with comment and whitespace preservation.
@@ -54,8 +55,15 @@
''');
for (var j = 0; j < modificationsPerRound; j++) {
- expect(
- () => generator.performNextModification(editor), returnsNormally);
+ /// Using [runZoned] to hide `package:yaml`'s warnings.
+ /// Test failures and errors will still be shown.
+ runZoned(() {
+ expect(
+ () => generator.performNextModification(editor), returnsNormally);
+ },
+ zoneSpecification: ZoneSpecification(
+ print: (Zone self, ZoneDelegate parent, Zone zone,
+ String message) {}));
}
});
}