我正在通过 intern-runner 脚本启动基于实习生的测试,如下所示:
<full_path>\intern\.bin\intern-runner config=unittest/intern
我的 unittest\intern.js 配置文件包含以下内容:
define({
reporters: [ "junit", "console", "lcovhtml", "runner" ],
excludeInstrumentation: /(?:dojo|intern|istanbul|reporters|unittest)(?:\\|\/)/,
suites: [ "unittest/all_intern.js" ],
forDebug: console.log("Customized intern config for test runner loaded successfully!"),
loader: {
packages: [
{ name: 'resources', location: 'abc/resources' },
{ name: 'stats', location: 'abc/resources/stats' },
{ name: 'nls', location: 'abc/nls' },
{ name: 'widgets', location: 'abc/widgets' },
{ name: 'views', location: 'abc/views' },
]
},
useLoader: {
'host-browser': 'node_modules/dojo/dojo.js'
},
tunnel: 'NullTunnel',
useSauceConnect: false,
webdriver: {
host: 'localhost',
port: 4444
},
proxyUrl: "http://localhost:8010/",
environments: [
{
browserName: 'chrome'
}
]
});
终端/命令窗口的输出看起来很有希望:
Customized intern config for test runner loaded successfully!
Listening on 0.0.0.0:9000
Starting tunnel...
Initialised chrome 40.0.2214.111 on XP
Chrome 浏览器确实启动了,我看到我的单元测试正在运行并传入浏览器内容。但是,控制永远不会回到终端/命令窗口——我看不到“634/634 测试通过”之类的东西,我必须按 Ctrl+C 来终止实习生运行程序。当然,不会生成代码覆盖率文件。这可能是由于我的文件结构吗?Intern 文件位于与这些单元测试完全不同的目录中——我没有从 Intern 库和单元测试文件(以及它们正在测试的产品文件)的公共父目录中调用 intern-runner。
如果这很重要,我可以创建一个图表来说明文件/目录结构。请注意,我确实稍微更改了实习生结构,例如:
<Dir_123>\intern\intern-2.2.2\bin\intern-runner.js
<Dir_123>\intern\intern-2.2.2\lib\<all_the_usual>
<Dir_123>\intern\intern-2.2.2\node_modules\<all_the_usual>
<Dir_123>\intern\.bin\intern-runner.cmd
即,我所做的改变是在“intern”之后插入一个额外的“intern-2.2.2”目录,并且包含intern-runner.cmd的“.bin”目录是“intern-2.2.2”的对等体。希望这不会令人困惑。:(
请注意,“proxyUrl”配置属性表示单元测试文件和产品文件可从 Web 服务器获得的 URL。通过为此目的配置proxyUrl,我做得对吗?如果我省略它,则不会运行,因为使用的默认值是 localhost:9000。我在 Github 上的“配置实习生”文章中看到 proxyUrl 是“仪器代理的 URL”,但我不太明白这意味着什么。