【问题标题】:How to run angular tests?如何运行角度测试?
【发布时间】:2017-12-06 08:44:51
【问题描述】:

我从https://github.com/angular-examples/toh-6.git克隆了示例项目

  1. 收到的依赖:

    发布获取

  2. 尝试运行测试:

    pub run angular_test --test-arg=--tags=aot --test-arg=--platform=dartium --test-arg=--reporter=expanded --verbose

输出:

PS Z:\Web\Test\dart_angular\external\toh-6> pub run angular_test --test-arg=--tags=aot --test-arg=--platform=dartium  --test-arg=--reporter=expanded --verbose
pub.bat serve test --port=0
Loading source assets...
Loading angular, test/pub_serve and dart_to_js_script_rewriter transformers...
Pub "serve" started on http://localhost:52953
Serving angular_tour_of_heroes test on http://localhost:52953
Finished compilation. Running tests...
pub.bat run test --tags=aot --platform=dartium --reporter=expanded --pub-serve=52953
00:00 +0: test\app_test.dart: (suite)
Skip: AppComponent tests need bootstrap equivalent for the Router init
00:00 +0 ~1: loading test\all_test.dart
00:00 +0 ~1 -1: loading test\all_test.dart [E]
Failed to load "test\all_test.dart":
Failed to run Dartium: Не удается найти указанный файл.


Command: dartium.exe --user-data-dir=C:\Users\k.ponomarev\AppData\Local\Temp\dart_test_e20a0131-da5c-11e7-9d6f-902b34b6196e http://localhost:52953/packages/test/src/runner/browser/static/index.html?managerUrl=ws%3A%2F%2Flocalhost%3A52956%2FmFXmvlRej%252BuoXwBhtyWjm1u67DweMIM9%2F0&debug=false --disable-extensions --disable-popup-blocking --bwsi --no-first-run --no-default-browser-check --disable-default-apps --disable-translate.
dart:async/future_impl.dart 22                             _Completer.completeError
dart:io-patch/process_patch.dart 412                       _ProcessImpl._start.<fn>
package:stack_trace/src/stack_zone_specification.dart 209  StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 119  StackZoneSpecification._registerCallback.<fn>
dart:async/zone.dart 1116                                  _rootRun
dart:async/zone.dart 1001                                  _CustomZone.run
dart:async/zone.dart 901                                   _CustomZone.runGuarded
dart:async/zone.dart 926                                   _CustomZone.bindCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 209  StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 119  StackZoneSpecification._registerCallback.<fn>
dart:async/zone.dart 1120                                  _rootRun
dart:async/zone.dart 1001                                  _CustomZone.run
dart:async/zone.dart 901                                   _CustomZone.runGuarded
dart:async/zone.dart 926                                   _CustomZone.bindCallback.<fn>
dart:async-patch/timer_patch.dart 21                       Timer._createTimer.<fn>
dart:isolate-patch/timer_impl.dart 366                     _Timer._runTimers
dart:isolate-patch/timer_impl.dart 394                     _Timer._handleMessage
dart:isolate-patch/isolate_patch.dart 151                  _RawReceivePortImpl._handleMessage
===== asynchronous gap ===========================
dart:async/zone.dart 1034                                  _CustomZone.registerCallback
dart:async/zone.dart 924                                   _CustomZone.bindCallback
dart:async/timer.dart 52                                   new Timer
dart:async/timer.dart 90                                   Timer.run
dart:io-patch/process_patch.dart 392                       _ProcessImpl._start
dart:io-patch/process_patch.dart 34                        Process.start
package:test/src/runner/browser/dartium.dart 66            new Dartium.<fn>.<fn>
===== asynchronous gap ===========================
dart:async/zone.dart 1034                                  _CustomZone.registerCallback
dart:async/zone.dart 924                                   _CustomZone.bindCallback
dart:async/schedule_microtask.dart 148                     scheduleMicrotask
dart:async/future.dart 182                                 new Future.microtask
package:test/src/runner/browser/dartium.dart 40            new Dartium.<fn>.<fn>
package:test/src/runner/browser/dartium.dart 119           new Dartium.<fn>
===== asynchronous gap ===========================

 ....

[test] GET all_test.dart.browser_test.dart => angular_tour_of_heroes|test/all_test.dart.browser_test.dart
00:00 +0 ~1 -1: Some tests failed.
Shutting down...
`pub serve` w

如何正确运行角度测试?

【问题讨论】:

    标签: angular unit-testing dart


    【解决方案1】:

    我找到了我的问题的解决方案。测试无法启动 dartium.exe。修复它:

    1. 将 c:\tools\dartium 添加到 PATH。
    2. 创建符号链接 dartium.exe 以启动 chrome.exe

      mklink dartium.exe c:\tools\dartium\chrome.exe

    我使用两种方法来启动测试:

    1. 在不同的控制台运行两个命令

      发布服务

      发布运行测试 --pub-serve=8081 -p dartium

    2. 如 (example):

      pub run angular_test --test-arg=--tags=aot --test-arg=--platform=dartium --test-arg=--reporter=expanded --verbose

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 2016-05-23
      • 1970-01-01
      相关资源
      最近更新 更多