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

Unified Diff: test/runner/compact_reporter_test.dart

Issue 1044953004: Gracefully handle tests that print. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 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/browser/runner_test.dart ('k') | test/runner/isolate_listener_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/compact_reporter_test.dart
diff --git a/test/runner/compact_reporter_test.dart b/test/runner/compact_reporter_test.dart
index f6729717ac13e68f857ad8b0718670d9a22d5ae3..35c5079829ec74459a15023cc979a2bb33e0ed34 100644
--- a/test/runner/compact_reporter_test.dart
+++ b/test/runner/compact_reporter_test.dart
@@ -110,14 +110,12 @@ void main() {
dart:async Future.Future.microtask
test.dart 10:15 main.<fn>
-
second error
test.dart 11:38 main.<fn>.<fn>
===== asynchronous gap ===========================
dart:async Future.Future.microtask
test.dart 11:15 main.<fn>
-
third error
test.dart 12:38 main.<fn>.<fn>
===== asynchronous gap ===========================
@@ -129,6 +127,109 @@ void main() {
+1 -1: wait
+1 -1: Some tests failed.""");
});
+
+ group("print:", () {
+ test("handles multiple prints", () {
+ _expectReport("""
+ test('test', () {
+ print("one");
+ print("two");
+ print("three");
+ print("four");
+ });""",
+ """
+ +0: test
+ one
+ two
+ three
+ four
+
+ +1: test
+ +1: All tests passed!""");
+ });
+
+ test("handles a print after the test completes", () {
+ _expectReport("""
+ // This completer ensures that the test isolate isn't killed until all
+ // prints have happened.
+ var testDone = new Completer();
+ var waitStarted = new Completer();
+ test('test', () {
+ waitStarted.future.then((_) {
+ new Future(() => print("one"));
+ new Future(() => print("two"));
+ new Future(() => print("three"));
+ new Future(() => print("four"));
+ new Future(testDone.complete);
+ });
+ });
+
+ test('wait', () {
+ waitStarted.complete();
+ return testDone.future;
+ });""", """
+ +0: test
+ +1: test
+ +1: wait
+ +1: test
+ one
+ two
+ three
+ four
+
+ +2: wait
+ +2: All tests passed!""");
+ });
+
+ test("interleaves prints and errors", () {
+ _expectReport("""
+ // This completer ensures that the test isolate isn't killed until all
+ // prints have happened.
+ var completer = new Completer();
+ test('test', () {
+ scheduleMicrotask(() {
+ print("three");
+ print("four");
+ throw "second error";
+ });
+
+ scheduleMicrotask(() {
+ print("five");
+ print("six");
+ completer.complete();
+ });
+
+ print("one");
+ print("two");
+ throw "first error";
+ });
+
+ test('wait', () => completer.future);""",
+ """
+ +0: test
+ one
+ two
+
+ +0 -1: test
+ first error
+ test.dart 24:11 main.<fn>
+
+ three
+ four
+ second error
+ test.dart 13:13 main.<fn>.<fn>
+ ===== asynchronous gap ===========================
+ dart:async scheduleMicrotask
+ test.dart 10:28 main.<fn>
+
+ five
+ six
+
+ +0 -1: wait
+ +1 -1: wait
+ +1 -1: Some tests failed.""");
+ });
+ });
}
void _expectReport(String tests, String expected, {List<String> args}) {
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | test/runner/isolate_listener_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698