如何进行角度测试?

时间:2017-12-06 08:44:51

标签: angular unit-testing dart

我从https://github.com/angular-examples/toh-6.git

克隆示例项目
  1. 收到依赖项:

    pub get

  2. 尝试运行测试:

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

  3. Outpu:

    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
    

    如何正确运行角度测试?

1 个答案:

答案 0 :(得分:0)

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

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

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

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

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

      pub serve

      pub run test --pub-serve = 8081 -p dartium

    2. 如(example):

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