Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: test/runner/set_up_all_test.dart

Issue 1400743002: Add support for setUpAll and tearDownAll. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/runner/engine_test.dart ('k') | test/runner/signal_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/set_up_all_test.dart
diff --git a/test/runner/set_up_all_test.dart b/test/runner/set_up_all_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2301eb499125534d4e7465dbc9f5b39b6ddbeae8
--- /dev/null
+++ b/test/runner/set_up_all_test.dart
@@ -0,0 +1,120 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+@TestOn("vm")
+
+import 'package:scheduled_test/descriptor.dart' as d;
+import 'package:scheduled_test/scheduled_stream.dart';
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../io.dart';
+
+void main() {
+ useSandbox();
+
+ test("an error causes the run to fail", () {
+ d.file("test.dart", r"""
+ import 'package:test/test.dart';
+
+ void main() {
+ setUpAll(() => throw "oh no");
+
+ test("test", () {});
+ }
+ """).create();
+
+ var test = runTest(["test.dart"]);
+ test.stdout.expect(consumeThrough(contains("-1: (setUpAll)")));
+ test.stdout.expect(consumeThrough(contains("-1: Some tests failed.")));
+ test.shouldExit(1);
+ });
+
+ test("doesn't run if no tests in the group are selected", () {
+ d.file("test.dart", r"""
+ import 'package:test/test.dart';
+
+ void main() {
+ group("with setUpAll", () {
+ setUpAll(() => throw "oh no");
+
+ test("test", () {});
+ });
+
+ group("without setUpAll", () {
+ test("test", () {});
+ });
+ }
+ """).create();
+
+ var test = runTest(["test.dart", "--name", "without"]);
+ test.stdout.expect(never(contains("(setUpAll)")));
+ test.shouldExit(0);
+ });
+
+ test("doesn't run if no tests in the group are selected", () {
+ d.file("test.dart", r"""
+ import 'package:test/test.dart';
+
+ void main() {
+ group("group", () {
+ setUpAll(() => throw "oh no");
+
+ test("with", () {});
+ });
+
+ group("group", () {
+ test("without", () {});
+ });
+ }
+ """).create();
+
+ var test = runTest(["test.dart", "--name", "without"]);
+ test.stdout.expect(never(contains("(setUpAll)")));
+ test.shouldExit(0);
+ });
+
+ test("doesn't run if no tests in the group match the platform", () {
+ d.file("test.dart", r"""
+ import 'package:test/test.dart';
+
+ void main() {
+ group("group", () {
+ setUpAll(() => throw "oh no");
+
+ test("with", () {}, testOn: "browser");
+ });
+
+ group("group", () {
+ test("without", () {});
+ });
+ }
+ """).create();
+
+ var test = runTest(["test.dart"]);
+ test.stdout.expect(never(contains("(setUpAll)")));
+ test.shouldExit(0);
+ });
+
+ test("doesn't run if the group doesn't match the platform", () {
+ d.file("test.dart", r"""
+ import 'package:test/test.dart';
+
+ void main() {
+ group("group", () {
+ setUpAll(() => throw "oh no");
+
+ test("with", () {});
+ }, testOn: "browser");
+
+ group("group", () {
+ test("without", () {});
+ });
+ }
+ """).create();
+
+ var test = runTest(["test.dart"]);
+ test.stdout.expect(never(contains("(setUpAll)")));
+ test.shouldExit(0);
+ });
+}
« no previous file with comments | « test/runner/engine_test.dart ('k') | test/runner/signal_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698