Natalie has been cranking on the test package since the beginning of the year. You should start taking a look. - Kevin
They have their tearDowns and their setUps, and one man in his time tests many units.
Hello Dartisans!
After several months of work, we’re nearing the release of a stable version of the test package, formerly known as unittest. In fact, all the features we wanted for the stable release are in place and all the bugs we know about are squashed. But since this is a pretty important piece of infrastructure for a lot of Dart users, though, we want to make absolutely sure that it’s solid before we put a stamp on it and call it truly stable. So we’re putting out a release candidate: version 0.12.0-rc.1.
The central feature of version 0.12.0 is the test runner. Rather than running each test file individually, they’re run via pub run test:test. This command on its own will run every test in your package, but a single test can also be run with pub run test:test path/to/test.dart, and all the tests in a directory can be run with pub run test:test path/to/dir.
The test runner also makes it way easier to run browser tests. Just pass the --platform flag: pub run test:test --platform chrome. It’ll handle compiling the tests to JS, starting the browser, and loading the tests. All the results will be available right there on the command line (or wherever you ran the test command), side by side with results from the VM or other browsers if you run on multiple platforms at once. Supported browsers include Chrome, Firefox, Safari, Internet Explorer, Dartium, Dartium Content Shell, and PhantomJS.
One of the major design goals of test 0.12.0 is making test configuration declarative. There are several types of declarative metadata that can be attached to tests, groups, and test suites, but the most important is @TestOn, which specifies which platforms a test is supposed to run on. It takes a string which describes the supported platforms. You can check out the full syntax for platform selectors, but for now the most important values are vm and browser. Here’s how you’d write a VM-only test:
@TestOn("vm")
import "dart:io";
import "package:test/test.dart";
void main() {
// ...
}
To learn more about these and other exciting new features, check out the README.
So what’s next after 0.12.0? For a full list of stuff we have planned, you can check out the 1.0.0 milestone on GitHub, but there are a couple big things that we’re particularly interested in. The biggest of these is debugging support, which we plan to provide in one form or another across all supported browsers and the VM. We’re also going to add a package-wide configuration file for the test runner, and there are a number of packages that we want to help make compatible with 0.12.0 such as scheduled_test, guinness, and mock.
So, try it out! Just change your dependency on unittest to test and bump up the version range:
dev_dependencies:
test: "^0.12.0-rc.1"
- Natalie
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
c:\msys64\home\dynaxis\work\seed>pub run test -p firefox test
Failed to create server socket (OS Error: Failed to start accept), address = loc
alhost, port = 0
dart:isolate _RawReceivePortImpl._handleMessage
This is an unexpected error. Please file an issue at http://github.com/dart-lang
/test
with the stack trace and instructions for reproducing the error.
Unhandled exception:
Uncaught Error: SocketException: Failed to create server socket (OS Error: Faile
d to start accept), address = localhost, port = 0
Stack Trace:
#0 _NativeSocket.bind.<anonymous closure> (dart:io-patch/socket_patch.dart:
502)
#1 _RootZone.runUnary (dart:async/zone.dart:1155)
#2 _Future._propagateToListeners.handleValueCallback (dart:async/future_imp
l.dart:494)
#3 _Future._propagateToListeners (dart:async/future_impl.dart:577)
#4 _Future._completeWithValue (dart:async/future_impl.dart:368)
#5 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:
422)
#6 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#7 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#8 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar
t:143)
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:886)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar
t:143)
--
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
I haven't seen support for this but I also run into a situation where I needed it.
You could just create an issue in the test GitHub repo and see what happens.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
The `--name` and `--plain-name` are better replacements. Currently the problem is that debugging doesn't work when tests are run with `pub run test ...`. You just modify you launch configuration to specify which test you want to run.
--
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
If you create an HTML page for your test, that'll work okay – I think.We have no done work to support manual test control in a browser, though. Filtering by test, etc.
--
Even w/ these, do you still want solo_test?We've had to fight A LOT to eliminate solo_test when they were unintentionally committed to source repos. We'd don't want to add it back if we can provide other means to get the same behavior.
I think the new scheme is a big advantage if you have tool support. If you have a view that shows all the tests in a file or a package and you click it for execution, it just passes the test name to the test runner and you have selected a single test to run without changing the code.
--
Vadim: I explain in this issue why we decided not to support a notion of "solo". In the long term, it'll be much easier to get good tool support for the command-line argument—this is how most other test frameworks work, so most IDEs have good support for it.