| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013, 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 /// A unit test library for running groups of tests in a browser, instead of the | |
| 6 /// entire test file. This is especially used for large tests files that have | |
| 7 /// many subtests, so we can mark groups as failing at a finer granularity than | |
| 8 /// the entire test file. | |
| 9 /// | |
| 10 /// To use, import this file, and call [useHtmlIndividualConfiguration] at the | |
| 11 /// start of your set sequence. Important constraint: your group descriptions | |
| 12 /// MUST NOT contain spaces. | |
| 13 library unittest.html_individual_config; | |
| 14 | |
| 15 import 'dart:html'; | |
| 16 import 'unittest.dart' as unittest; | |
| 17 import 'html_config.dart' as htmlconfig; | |
| 18 | |
| 19 class HtmlIndividualConfiguration extends htmlconfig.HtmlConfiguration { | |
| 20 HtmlIndividualConfiguration(bool isLayoutTest) : super(isLayoutTest); | |
| 21 | |
| 22 void onStart() { | |
| 23 var uri = Uri.parse(window.location.href); | |
| 24 | |
| 25 var groups = 'group='.allMatches(uri.query).toList(); | |
| 26 | |
| 27 if (groups.length > 1) { | |
| 28 throw new ArgumentError('More than one "group" parameter provided.'); | |
| 29 } | |
| 30 | |
| 31 var testGroupName = uri.queryParameters['group']; | |
| 32 | |
| 33 if (testGroupName != null) { | |
| 34 var startsWith = "$testGroupName${unittest.groupSep}"; | |
| 35 unittest.filterTests( | |
| 36 (unittest.TestCase tc) => tc.description.startsWith(startsWith)); | |
| 37 } | |
| 38 super.onStart(); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 void useHtmlIndividualConfiguration([bool isLayoutTest = false]) { | |
| 43 unittest.unittestConfiguration = | |
| 44 isLayoutTest ? _singletonLayout : _singletonNotLayout; | |
| 45 } | |
| 46 | |
| 47 final _singletonLayout = new HtmlIndividualConfiguration(true); | |
| 48 final _singletonNotLayout = new HtmlIndividualConfiguration(false); | |
| OLD | NEW |