Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 如何让content_shell运行测试?_Unit Testing_Dart - Fatal编程技术网

Unit testing 如何让content_shell运行测试?

Unit testing 如何让content_shell运行测试?,unit-testing,dart,Unit Testing,Dart,这方面已经有了问题和答案,但我认为这是新的东西。我正试图让drone.io在content_shell中运行我的测试。我已经按照说明启动了X服务器。通过download\u contentshell.sh脚本下载内容\u shell。并根据我从这里找到的答案和其他来源得到的指示执行内容。问题是它们都不起作用。content_shell不会运行我的测试,除非我给它一个绝对文件路径,但如果我这样做,当它运行测试时,它会失败,因为它无法使用所需的导入。下面是我在drone.io设置中运行测试脚本的步骤

这方面已经有了问题和答案,但我认为这是新的东西。我正试图让drone.io在content_shell中运行我的测试。我已经按照说明启动了X服务器。通过download\u contentshell.sh脚本下载内容\u shell。并根据我从这里找到的答案和其他来源得到的指示执行内容。问题是它们都不起作用。content_shell不会运行我的测试,除非我给它一个绝对文件路径,但如果我这样做,当它运行测试时,它会失败,因为它无法使用所需的导入。下面是我在drone.io设置中运行测试脚本的步骤

sudo启动xvfb
发布安装
test/run.sh
下面是run.sh脚本

#/bin/bash
你的贝壳是什么
如果[$?-ne 0]];然后
$DART\u SDK/。/chromiu/下载\u contentshell.sh
解压缩内容\u shell-linux-x64-release.zip
cs_路径=$(ls-d drt-*)
路径=$cs\u路径:$PATH
fi
结果=$(content_shell--args--转储渲染树测试/index.html 2>&1)
echo-e“$results”
#检查DumpRenderTree测试是否正确
#失败,因为它总是返回0
如果[[“$results”==*“某些测试失败”*]]
然后
出口1
fi
如果[[“$results”==*”异常:“*]”
然后
出口1
fi
这是dart测试文件

import'包:unittest/unittest.dart';
导入“package:unittest/html_config.dart”;
导入“dart:html”;
导入“dart:async”;
进口“包装:聚合物/聚合物.dart”;
main(){
//确保Polymer正在查找绑定变量。。。
addXParent();
initPolymer();
removeXParent();
设置(addXParent);
拆卸(移除透明材料);
组(“遇到映射”,(){
测试('具有画布元素',(){
新定时器(
新的持续时间(毫秒:2500),
expectAsync0(){
期待(
querySelector('Conference-map').shadowRoot.querySelector('canvas'),
isNotNull
);
})
);
});
测试(“包含文件输入元素”,(){
新定时器(
新的持续时间(毫秒:2500),
expectAsync0(){
期待(
querySelector('Conference-map').shadowRoot.querySelector('input'),
isNotNull
);
期待(
querySelector('Conference-map').shadowRoot.querySelector('input'),
新的isInstanceOf()
);
期待(
querySelector('Conference-map')。shadowRoot.querySelector('input')。属性['type'],
包含('文件')
);
})
);
});
});
}
addXParent(){
document.body.append(createElement(“”));
}
removeXParent(){
queryselectoral('conference-map').forEach((el)=>el.remove());
}
createElement(字符串html)=>
html(html,treesanizer:new nulltreesanizer());
类NullTreeSInitiatizer实现NodeTreeSaninitizer{
void sanitizeTree(节点){}
}
以及index.html文件


我已经看到这个测试正在运行,所有发生的事情都是content_shell没有退出,阻止脚本完成,因此超时。您可以找到此项目的整个源代码

这真把我逼疯了。这是虫子吗?如果有区别,我使用的dart版本是“dart SDK版本1.1.0-dev.4.0”


此外,该测试在“Dart编辑器版本1.1.0.dev_04_00(dev)”中运行得非常好,只是在使用content_shell时运行得不好,我在询问Chris Strom有关它的情况后,才发现它工作正常。似乎我没有使用下面的

useHtmlConfiguration(true);
看起来很傻,因为我很确定我在别的地方看到过。你还需要确定,我一直在做这件事

import 'package:unittest/html_config.dart';
完成了,因为那是

useHtmlConfiguration(true);

来自。这将确保在所有测试完成后发送关闭窗口的正确信号。现在我的无人机测试通过了:-)

新的
测试
软件包支持它

*\u test.dart
文件中的库语句上方添加
@TestOn('browser')
,然后运行
pub global activate test
以安装新的测试运行程序,并运行
pub global run test-pcontent shell
以运行测试

在发布稳定版本之前,请使用
pub global activate test'>0.12.0-beta.6'
pub global activate-sgitgit@github.com:dart lang/test.git


此外,不支持当前随Dart发布的
content\u shell
版本。目前只支持最新版本(请参阅),但现在也支持Dartium、Chrome、FireFox和Phantom.js。

我没有答案,但投票支持这个问题是一个好的开始:@zoechi实际上在这个问题的背景下,投票支持这个问题不是一个好的开始,但你还是说服了我投票支持它。