OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 @TestOn("vm") |
| 6 |
| 7 import 'package:scheduled_test/descriptor.dart' as d; |
| 8 import 'package:scheduled_test/scheduled_stream.dart'; |
| 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 |
| 11 import '../io.dart'; |
| 12 |
| 13 void main() { |
| 14 useSandbox(); |
| 15 |
| 16 test("an error causes the run to fail", () { |
| 17 d.file("test.dart", r""" |
| 18 import 'package:test/test.dart'; |
| 19 |
| 20 void main() { |
| 21 setUpAll(() => throw "oh no"); |
| 22 |
| 23 test("test", () {}); |
| 24 } |
| 25 """).create(); |
| 26 |
| 27 var test = runTest(["test.dart"]); |
| 28 test.stdout.expect(consumeThrough(contains("-1: (setUpAll)"))); |
| 29 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); |
| 30 test.shouldExit(1); |
| 31 }); |
| 32 |
| 33 test("doesn't run if no tests in the group are selected", () { |
| 34 d.file("test.dart", r""" |
| 35 import 'package:test/test.dart'; |
| 36 |
| 37 void main() { |
| 38 group("with setUpAll", () { |
| 39 setUpAll(() => throw "oh no"); |
| 40 |
| 41 test("test", () {}); |
| 42 }); |
| 43 |
| 44 group("without setUpAll", () { |
| 45 test("test", () {}); |
| 46 }); |
| 47 } |
| 48 """).create(); |
| 49 |
| 50 var test = runTest(["test.dart", "--name", "without"]); |
| 51 test.stdout.expect(never(contains("(setUpAll)"))); |
| 52 test.shouldExit(0); |
| 53 }); |
| 54 |
| 55 test("doesn't run if no tests in the group are selected", () { |
| 56 d.file("test.dart", r""" |
| 57 import 'package:test/test.dart'; |
| 58 |
| 59 void main() { |
| 60 group("group", () { |
| 61 setUpAll(() => throw "oh no"); |
| 62 |
| 63 test("with", () {}); |
| 64 }); |
| 65 |
| 66 group("group", () { |
| 67 test("without", () {}); |
| 68 }); |
| 69 } |
| 70 """).create(); |
| 71 |
| 72 var test = runTest(["test.dart", "--name", "without"]); |
| 73 test.stdout.expect(never(contains("(setUpAll)"))); |
| 74 test.shouldExit(0); |
| 75 }); |
| 76 |
| 77 test("doesn't run if no tests in the group match the platform", () { |
| 78 d.file("test.dart", r""" |
| 79 import 'package:test/test.dart'; |
| 80 |
| 81 void main() { |
| 82 group("group", () { |
| 83 setUpAll(() => throw "oh no"); |
| 84 |
| 85 test("with", () {}, testOn: "browser"); |
| 86 }); |
| 87 |
| 88 group("group", () { |
| 89 test("without", () {}); |
| 90 }); |
| 91 } |
| 92 """).create(); |
| 93 |
| 94 var test = runTest(["test.dart"]); |
| 95 test.stdout.expect(never(contains("(setUpAll)"))); |
| 96 test.shouldExit(0); |
| 97 }); |
| 98 |
| 99 test("doesn't run if the group doesn't match the platform", () { |
| 100 d.file("test.dart", r""" |
| 101 import 'package:test/test.dart'; |
| 102 |
| 103 void main() { |
| 104 group("group", () { |
| 105 setUpAll(() => throw "oh no"); |
| 106 |
| 107 test("with", () {}); |
| 108 }, testOn: "browser"); |
| 109 |
| 110 group("group", () { |
| 111 test("without", () {}); |
| 112 }); |
| 113 } |
| 114 """).create(); |
| 115 |
| 116 var test = runTest(["test.dart"]); |
| 117 test.stdout.expect(never(contains("(setUpAll)"))); |
| 118 test.shouldExit(0); |
| 119 }); |
| 120 } |
OLD | NEW |