我想根据通过启动命令传递的自定义参数加载测试脚本来开始实习测试。 要做到这一点,我试图要求在测试中的具体测试脚本,但我得到Attempt to require unloaded module
错误。 这是我的代码设置。有人可以帮助解决这个问题,或者采取一些替代方法来完成这项工作。负载测试csript intern.js内测试
define(function (require) {
var intern = require('intern');
var AdvalentAutomationTestSuite = require('intern!object');
AdvalentAutomationTestSuite({
name: 'Advalent Automation Test',
'AdvalentTestSets': function() {
return this.remote
.then(function() {
var product = intern.args.product;
var script = 'Automation/TestScripts/FRG/' + product + '-Config';
require(script)
})
},
});
});
更新:
intern.js
包括文件:
define(function (require) {
var intern = require('intern');
console.log(intern)
return {
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
defaultTimeout: 120000,
capabilities: {
'selenium_version': '2.48.2',
},
environments: [
{browserName: 'chrome', version: '48', platform: ['WINDOWS'], chromeOptions: {args: ['start-maximized']}},
],
maxConcurrency: 3,
tunnel: 'NullTunnel',
reporters: [
{id: 'JUnit', filename: 'test-reports/report.xml'},
{id: 'Runner'},
],
Loaders: {
'host-node': 'dojo/dojo',
'host-browser': 'node_modules/dojo/dojo.js'
},
loaderOptions: {
packages: [{name: 'intern-tutorial', location: '.'}]
},
functionalSuites: [
'Automation/TestScripts/FRG/FRG-Config',
],
defaultTimeout: 70000,
excludeInstrumentation: /^(?:tests|node_modules)\//
}
});
感谢@ jaso0x43这是启示。感谢分享知识。至于我的问题的解决方法,我解决了如果从'intern.js'文件。我也添加了我的解决方案作为在这篇文章中的答案。请在回顾我的方式后建议是否有更好的方法来做到这一点。 – CodeBlooded