黄瓜/阿鲁巴交互式测试

时间:2013-03-30 19:32:58

标签: ruby cucumber command-line-interface thor aruba

您好,我目前正在玩黄瓜/阿鲁巴测试,到目前为止真的很喜欢它。但我偶然发现了互动问题。

我的应用程序会监视文件夹中的更改,并打印出类似“更改文件”的内容。此刻。

如果我输入jsbreeze watchFolder foo,应用程序会开始观看我的文件夹并将其打印到控制台:

"观看:foo"

我可以像黄瓜/阿鲁巴一样轻松地测试这个:

Scenario: jsbreeze should be able to watch a folder
    Given a directory named "foo"
    When I run `jsbreeze watchFolder foo` interactively
    And I wait for output to contain "Watching: foo"

但我确实想测试它是否检测到变化,所以我希望我可以做这样的事情

Scenario: jsbreeze should be able to watch multiple folders
    Given a directory named "foo"
    When I run `jsbreeze watchFolder foo,.` interactively
    And I wait for output to contain "Watching: foo,."
    Then I run `touch foo/test.js`
    And I wait for output to contain "Change detected"

但这似乎不起作用。我认为这是因为我的应用程序在那一刻以交互方式运行,因此我无法像触摸那样运行命令。有没有人遇到这样的问题并且可能知道解决方法?

完整代码在github上: github-link

非常感谢每一个帮助

编辑:我取得了一些进展

我创建了一个新步骤,它生成一个子进程,然后执行touch命令。我可以清楚地看到触摸的文件是在foo文件夹中创建的,但是我的场景仍然无法看到输出。

我的步骤如下:

When /^I run "([^"]*)" in a new process$/ do |command|
    @process = ChildProcess.send(:build,*command.split(' '))
    @process.start
    sleep 10
end

我的情景:

Scenario: jsbreeze should be able to watch multiple folders
    Given a directory named "foo"
    When I run `jsbreeze watchFolder foo,.` interactively
    And I run "touch tmp/aruba/foo/test.js" in a new process
    And I wait for output to contain "Change detected"

0 个答案:

没有答案