首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >drone.io无头测试

drone.io无头测试
EN

Stack Overflow用户
提问于 2013-10-28 21:22:50
回答 2查看 687关注 0票数 3

您能在drone.io上运行基于浏览器的Dart单元测试吗?我最后一个失败的构建是这里。我尝试过sudo start xvfb,但我不知道如何将它指向启动单元测试的index.html文件,有人知道如何做吗?我应该说,我对任何实际的DOM测试都不感兴趣,但是我的库导入了' dart :html‘,所以我不能在基本的dart配置中运行它。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-29 04:53:55

这是我的xml2json库的无人机脚本

代码语言:javascript
复制
pub install
sudo start xvfb
content_shell --args --dump-render-tree test/xml2json.html | sed -n 2p | grep PASS

它使用基于HTML的标准单元测试,即包含HTML()。

grep只是检查通过/失败,您可能不需要这个。

票数 2
EN

Stack Overflow用户

发布于 2013-10-29 00:30:17

更新:修改了构建脚本以下载content_shell。还在hop任务createUnitTestTask()中更新了指向createUnitTestTask()的路径。

我使用酒馆套餐对无人机进行无头测试。对于一个相对简单的示例,您可以参考单普罗库。但是,基本步骤是将以下内容作为开发人员依赖项添加到pubspec.yaml中:

代码语言:javascript
复制
hop: '>=0.27.0'
unittest: '>=0.9.0 <0.10.0'

在项目根目录中创建一个工具目录,并添加一个文件hop_runner.dart。我的看上去像这样:

代码语言:javascript
复制
library dumprendertree;

import 'package:hop/hop.dart';
import 'dart:io';
import 'dart:async';

main(List<String> args) {
  addTask('test', createUnitTestTask());
  runHop(args);
}

Task createUnitTestTask() {
  return new Task((TaskContext tcontext) {
    tcontext.info("Running Unit Tests....");
    var result = Process.run('./content_shell',
        ['--dump-render-tree','test/simplot_tests.html'])
        .then((ProcessResult process) {
          tcontext.info(process.stdout);
        });
    return result;
  });
}

您可以看到它在测试目录中调用我的simplot_tests.html文件的位置。

那我的无人机剧本是:

代码语言:javascript
复制
$DART_SDK/../chromium/download_contentshell.sh
unzip content_shell-linux-x64-release.zip
mv drt*/* .
pub get
sudo start xvfb
dart --checked tool/hop_runner.dart test

simplot_tests.html文件如下所示:

代码语言:javascript
复制
<!DOCTYPE html>

<html>
  <head>
    <title>Unit Tests for Simplot Library</title>
  </head>
  <body>
    <script type="text/javascript" src="packages/unittest/test_controller.js"></script>
    <script type="text/javascript" src="packages/browser/dart.js"></script>
    <script type="application/dart" src="simplot_tests.dart"></script>
  </body>
</html>

最后,省道文件看起来如下所示:

代码语言:javascript
复制
import 'package:simplot/simplot.dart';
import 'package:unittest/unittest.dart';
import 'package:unittest/html_enhanced_config.dart';
import 'dart:html';
import 'dart:math';

part 'tests/logarithmic_tests.dart';
part 'tests/time_stamp_tests.dart';
part 'tests/axis_configure_tests.dart';
part 'tests/create_single_plot.dart';
part 'tests/create_multiple_plots.dart';
part '../lib/src/axis_config.dart';

void main() {
  print('Running unit tests for simplot library.');
  useHtmlEnhancedConfiguration();
  group('All Tests:', (){
    test('test of logarithmic functions', () => logarithmicTests());
    test('test of time stamp', () => timeStampTests());
    test('test of axis configuration', () => axisConfigTests());
    test('test of creating a single plot', () => createSinglePlot());
    test('test of creating multiple plots', () => createMultiplePlots());
  });
}

希望这能让你开始。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19645322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档