简体   繁体   English

使用简单的GUI运行黄瓜功能文件

[英]Using a simple GUI to run a Cucumber Feature File

I am utilizing the "shoes" tool to create a window with a button in the middle. 我正在利用“鞋子”工具创建一个中间带有按钮的窗口。 I would like the user to be able click the button and then the program runs a Cucumber feature file, but I don't know how to run a feature file from within a class or if its possible. 我希望用户能够单击该按钮,然后程序运行Cucumber功能文件,但是我不知道如何从类中运行功能文件,或者不知道如何运行。 Very new at this so any advice is appreciated. 在此非常新,因此任何建议都值得赞赏。 Let me know if more information is necessary. 让我知道是否需要更多信息。

Try something like 尝试类似

Shoes.app do
  @s = stack {}

  button "Run Cucumber" do
    @out = `cucumber`
    @s.clear { para @out }
  end
end

From the cucumber documentation you just run it as any other rake task from within your app: Cucumber文档中,您可以像在应用程序中执行任何其他rake任务一样运行它:

require 'rubygems'
require 'cucumber/rake/task'

Cucumber::Rake::Task.new(:features) do |t|
  t.cucumber_opts = "--format pretty" # Any valid command line option can go here.
end

you then just need to put it into a shoes window like so: 然后,您只需将其放入鞋窗,如下所示:

require 'rubygems'
require 'cucumber/rake/task'
require 'shoes'

Shoes.app {
  @push = button "Run Features"
  @note = para "Haven't run features"
  @push.click {
    result = Cucumber::Rake::Task.new(:features) do |t|
      t.cucumber_opts = "--format pretty" # Any valid command line option can go here.
    end
    @note.replace result
  }
}

or something like that, I haven't actually tested this but look at the outputs and read the documentation and you'll be fine. 或类似的东西,我还没有实际测试过,但是查看输出并阅读文档,就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM