简体   繁体   English

在Rubymine中运行带标签的RSpec测试

[英]Running tagged RSpec tests within Rubymine

I am able to run tagged RSpec tests from the command line by tagging the test as follows: 通过将测试标记如下,我可以从命令行运行标记的RSpec测试:

context "sample test description", :mytag do 上下文“样本测试描述”,:mytag做

     (do some stuff)

end 结束

I execute the command line as follows and this works fine: bundle exec rspec -fd -t mytag 我按如下所示执行命令行,这可以正常工作: bundle exec rspec -fd -t mytag

The problem is that I am trying to run from within Rubymine 2017.2.3 and utilize the above tag "mytag". 问题是,我试图从内部的RubyMine 2017年2月3日运行,并利用上述标签“mytag”。

I've Googled quite a bit but have found no solutions. 我已经用Google搜索了很多,但没有找到解决方案。

The closest I think I have come, is by navigating to Run -> Edit Configurations and trying to specify the tag option in the Runner options field, but haven't gotten it to work. 我认为最接近的方法是,导航到“运行”->“编辑配置”,并尝试在“运行器选项”字段中指定标签选项,但尚未使其工作。 I've tried several variations. 我尝试了几种变体。

I also just put --h in Runner options and ran and it does bring up the help. 我也只是将--h放在Runner选项中并运行,它确实带来了帮助。 But --t / --tags does not seem to be recognized the same as it is in the command line. 但是--t / --tags似乎与命令行中的识别不同。

Can anyone tell me if they have gotten this to work? 谁能告诉我他们是否可以使用此功能?

Thanks 谢谢

Well, I figured it out myself. 好吧,我自己弄清楚了。 It appears that you have to use -t, not --tags. 看来您必须使用-t,而不是--tags。 Secondly, I was starting the test by right-clicking on a shared example within my rspec. 其次,我通过右键单击rspec中的一个共享示例来开始测试。 What this seems to do is add its own tagging by performing the right click. 这似乎是通过执行右键单击来添加自己的标记。 However, if I right-click on the file tab at top and then Select 'Run spec 'spec_name' from the menu, then the tagging set in Edit Configurations will work. 但是,如果我右键单击顶部的文件选项卡,然后从菜单中选择“运行规格'spec_name”,则在“编辑配置”中设置的标记将起作用。

The run console will show what tags it ran with. 运行控制台将显示其运行的标签。 Example below: 下面的例子:

Run options: include {:focus=>true, :mytag=>true} 运行选项:include {:focus => true,:mytag => true}

So, in short, add -t {tagname} to Run options field and run the entire RSPEC file. 简而言之,将-t {tagname}添加到“运行选项”字段中,然后运行整个RSPEC文件。

I think that's because, by default, RubyMine uses a "rails" task, not an rspec task and the parameters are not passed along. 我认为这是因为,默认情况下,RubyMine使用“ rails”任务,而不是rspec任务,并且不会传递参数。 When I created an rspec task, I succeeded in passing the parameters I needed to the runner. 创建rspec任务时,我成功地将所需的参数传递给了运行器。

Hope this helps! 希望这可以帮助! 在此处输入图片说明

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

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