【问题标题】:grunt cucumberjs multiple parallel runsgrunt cucumberjs 多个并行运行
【发布时间】:2014-01-16 14:08:39
【问题描述】:

我正在尝试通过 grunt 运行 cucumberjs 测试以获取浏览器堆栈功能矩阵。

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

grunt.initConfig
    qcumberbatch:
        options:
            steps: 'src/features/integration/steps'
            tags: '~@ShouldFail'
            browserstack:
                'browserstack.user' : process.env.BS_USER
                'browserstack.key' : process.env.BS_ACCESS_KEY
                'browserstack.tunnel' : 'true' # This was the secret!

            matrix: [
                browser: 'firefox'
                browser_version: '26.0'
                os: 'Windows'
                os_version : '7',
            ,
                browser : 'IE',
                browser_version : '9.0',
                os : 'Windows',
                os_version : '7',
                resolution : '1024x768'
            ]
            hub: "http://hub.browserstack.com/wd/hub"

        local:
            files:
                src: ['src/features/integration/*']
            options:
                hub: 'http://localhost:4444/wd/hub'
                matrix: ['firefox']

        browserstack:
            files:
                src: ['src/features/integration/*']

        failing:
            files:
                src: ['src/features/integration/*']
            options:
                tags: '@ShouldFail'

默认选项是在 Windows 7 上使用 firefox 和 IE 对 browserstack 运行,本地测试覆盖 browserstack 以使用本地 selenium webdriver hub。

黄瓜世界是用一个构造函数来设置能力对象的:

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 之间通信功能?

【问题讨论】:

    标签: gruntjs cucumberjs


    【解决方案1】:

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

    但是,如果您对更加程序化的方法感兴趣,您可以很容易地实例化 Cucumber 运行时。 CLI 源代码非常简单,它是如何从代码中调用 Cucumber 的一个很好的示例。见https://github.com/cucumber/cucumber-js/blob/master/lib/cucumber/cli.js

    【讨论】:

    • 我曾考虑绑定到 CLI,但这需要在所需步骤文件中的文件中具有功能。在我看来,支持代码加载器在仅从文件路径加载代码方面存在问题,而不是允许运行时传入具有步骤定义的对象。但是,这在其他页面中存在各种架构问题。可能超出了这个问题的范围。如果我将此作为 0.6 的增强功能发布在 github 上,您是否有兴趣更改 API?
    • 当然,我们可以改进它。您是否检查过我们如何在浏览器上下文中注入支持代码?那会有所帮助。 github.com/cucumber/cucumber-js/blob/master/example/…
    • 嗯,我没看到。我会看看并发布一些东西。
    【解决方案2】:

    可能的解决方案:

    使用所有功能的 blob 将文件写入 grunt 文件中的已知位置。然后,启动几个 cucumberjs 运行,使用进程环境变量告诉世界使用 blob 中的哪个功能。

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

    【讨论】:

    • 扩展这个想法,在 env var 中将功能作为 JSON 传递怎么样?然后在您的 World 中解析该 JSON 字符串并取回您的对象。
    猜你喜欢
    • 1970-01-01
    • 2014-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多