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

Unified Diff: test/utils.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/tear_down_all_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/utils.dart
diff --git a/test/utils.dart b/test/utils.dart
index acbec120cd9d2f55763eb1dc83fe87cb49e37cf6..966271696801994705fb0bda038889196c283e39 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -16,7 +16,10 @@ import 'package:test/src/backend/metadata.dart';
import 'package:test/src/backend/state.dart';
import 'package:test/src/backend/suite.dart';
import 'package:test/src/runner/application_exception.dart';
+import 'package:test/src/runner/engine.dart';
import 'package:test/src/runner/load_exception.dart';
+import 'package:test/src/runner/runner_suite.dart';
+import 'package:test/src/runner/vm/environment.dart';
import 'package:test/src/util/remote_exception.dart';
import 'package:test/test.dart';
@@ -284,8 +287,29 @@ Future expectTestBlocks(test(), stopBlocking(value)) async {
return future;
}
+/// Runs [body] with a declarer, runs all the declared tests, and asserts that
+/// they pass.
+Future expectTestsPass(void body()) async {
+ var engine = declareEngine(body);
+ var success = await engine.run();
+
+ for (var test in engine.liveTests) {
+ expectTestPassed(test);
+ }
+
+ expect(success, isTrue);
+}
+
/// Runs [body] with a declarer and returns the declared entries.
List<GroupEntry> declare(void body()) {
var declarer = new Declarer()..declare(body);
return declarer.build().entries;
}
+
+/// Runs [body] with a declarer and returns an engine that runs those tests.
+Engine declareEngine(void body()) {
+ var declarer = new Declarer()..declare(body);
+ return new Engine.withSuites([
+ new RunnerSuite(const VMEnvironment(), declarer.build())
+ ]);
+}
« no previous file with comments | « test/runner/tear_down_all_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698