Gruntjs grunt cucumberjs多个并行运行

Gruntjs grunt cucumberjs多个并行运行,gruntjs,cucumberjs,Gruntjs,Cucumberjs,我试图通过grunt运行cucumberjs测试,以获得browserstack功能矩阵 矩阵通常配置为“grunt”(qcuberbatch是本地grunt任务定义): 默认选项使用firefox和IE在Windows 7上运行browserstack,本地测试覆盖browserstack以使用本地selenium webdriver集线器 cucumber world由一个构造函数设置,该构造函数接受capabilities对象: module.exports = class World

我试图通过grunt运行cucumberjs测试,以获得browserstack功能矩阵

矩阵通常配置为“grunt”(qcuberbatch是本地grunt任务定义):

默认选项使用firefox和IE在Windows 7上运行browserstack,本地测试覆盖browserstack以使用本地selenium webdriver集线器

cucumber world由一个构造函数设置,该构造函数接受capabilities对象:

module.exports = class World
    ###
    Create a new world, assuming firefox capabilities.

    @param {string} browser property name from the `webdriver.Capabilities`
        list.
    ###
    constructor: (capabilities = {browserName: "firefox"})->
        @driver = new webdriver.Builder().
            usingServer(process.env.SELENIUM_HUB).
            withCapabilities(capabilities).build()

        @driver.manage().timeouts().setScriptTimeout(10000)
当从grunt运行这个时,问题是cucumberjs没有编程接口(我看到了)。如果无法在运行时配置要加载的几个功能块中的哪一个,我应该如何在cucumberjs运行和grunt之间通信这些功能?

可能的解决方案:

使用包含所有功能的blob将文件写入grunt文件中的已知位置。然后,开始几次cucumberjs运行,使用一个流程环境变量告诉世界要从blob使用哪种功能


我不喜欢这样,因为它涉及每次运行创建临时文件等。我更喜欢在配置World对象时找到一种以编程方式使用cucumberjs的方法。

我会按照我的建议使用您的解决方案和JSON对象


但是,如果您对一种更具编程性的方法感兴趣,那么可以非常轻松地实例化Cucumber运行时。CLI源代码非常简单,它是如何从代码中调用Cucumber的一个很好的示例。请参阅。

扩展这个想法,在env var中将这些功能作为JSON传递怎么样?然后在您的世界中解析JSON字符串并取回您的对象。我曾考虑绑定到CLI,但这需要在所需步骤文件中的文件中具有这些功能。在我看来,支持代码加载器只从文件路径加载代码,而不允许运行时传入带有步骤定义的对象,这是有问题的。然而,在其他页面中,这有各种各样的体系结构问题。可能超出了这个问题的范围。如果我在github上发布这篇文章作为对0.6的增强,您是否有兴趣修改API?当然,我们可以改进它。您是否检查过我们如何在浏览器上下文中注入支持代码?这可能会有帮助。嗯,我没看到。我来看看,然后贴些东西。
module.exports = class World
    ###
    Create a new world, assuming firefox capabilities.

    @param {string} browser property name from the `webdriver.Capabilities`
        list.
    ###
    constructor: (capabilities = {browserName: "firefox"})->
        @driver = new webdriver.Builder().
            usingServer(process.env.SELENIUM_HUB).
            withCapabilities(capabilities).build()

        @driver.manage().timeouts().setScriptTimeout(10000)