Test Runner Dart 是用于 Dart 测试文件的命令行测试运行器。当你的 Dart 项目处于正确的环境时(VM 或者 Browser),它能自动侦测并且运行所有测试。
示例代码:
bash> run_tests Checking Dart binaries... Dart binaries OK. Looking for Dart project in "./"... Found project "test-runner". Looking for test suites... Found 5 test suites (3 Standalone VM, 2 Dartium). Checking browser binaries... Browser binaries OK. Running all tests... Test suite passed: /vm_ok_test.dart Test suite passed: /subdir/vm_in_subdir_ok_test.dart Test suite failed: /vm_fail_test.dart Detailed results of test suite vm_fail_test.dart: ┌──────────────────────────────────────────────── │ FAIL: QuickSort │ Expected: equals [1, 2, 3, 4, 5] ordered │ Actual: [3, 5, 2, 4, 1] │ Which: was <3> instead of <1> at location [0] │ ... │ FAIL: Partition │ Expected: <1> │ Actual: <0> │ ... │ 0 PASSED, 2 FAILED, 0 ERRORS └──────────────────────────────────────────────── Test suite passed: /browser_ok_test.dart Test suite passed: /browser_ok_with_html_test.dart Summary: 1 TEST SUITE(S) FAILED. 4 TEST SUITE(S) PASSED