简体   繁体   English

设置黄瓜以使用Watir测试sinatra应用

[英]Set up cucumber to test sinatra app using watir

I'm developing a sinatra app, and I'd like to test it using cucumber and watir. 我正在开发一个sinatra应用程序,我想使用黄瓜和watir对其进行测试。 My problem is that I'm not sure how to set up my env.rb file to run the sinatra app, all the examples I've found use webrat or capybara or something else that isn't watir. 我的问题是我不确定如何设置env.rb文件来运行sinatra应用程序,我发现的所有示例都使用webrat或capybara或其他非watir的示例。 Is there a way to start my sinatra app from cucumber without using webrat or another testing framework that isn't watir, or should I just start my sinatra app manually before running my tests? 有没有一种方法可以从黄瓜中启动我的sinatra应用程序,而无需使用webrat或不是watir的其他测试框架,还是应该在运行测试之前手动启动我的sinatra应用程序?

env.rb executes an arbitrary Ruby code as a part of Cucumber setup, so you should be able to start your app or do whatever else you need. env.rb作为Cucumber设置的一部分执行一个任意的Ruby代码,因此您应该能够启动您的应用程序或执行所需的其他任何操作。 Try: 尝试:

require 'YourApp'
YourApp.run!

Having said that, it might not be the most logical place to do. 话虽如此,这可能不是最合乎逻辑的做法。 An automated build cycle for a web app usually consists of the following steps: Web应用程序的自动构建周期通常包括以下步骤:

  1. Build: compile, copy necessary files, package a binary, etc. 构建:编译,复制必要的文件,打包二进制文件等。
  2. Run unit tests 运行单元测试
  3. Deploy: put the application on a target server 部署:将应用程序放置在目标服务器上
  4. Run integration/feature tests 运行集成/功能测试

Cucumber and Watir are all about Step 4; Cucumber和Watir都与步骤4有关; therefore, env.rb usually starts a browser. 因此,env.rb通常会启动浏览器。 What you are trying to do belongs logically in Step 3, IMHO. 从逻辑上讲,您要尝试做的事情属于恕我直言。

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

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