需要帮助为Rails应用程序设置基于UI的测试

时间:2021-05-13 23:31:29

I am leading a team which develops application based on Ruby on Rails. Since the application was small, automated testing was not given much importance. But lately it has started growing in size. I am seriously thinking of enforcing the testing discipline in the team.

我正在领导一个基于Ruby on Rails开发应用程序的团队。由于应用程序很小,因此自动化测试并不重要。但最近它的规模已经开始增长。我正在认真考虑在团队中执行测试规程。

For all the new code that is being committed, I want my developers to do a 100% code coverage. But the problem is that they are resistant to write tests for UI related changes. I read online that Selenium is one of the solutions for UI testing.

对于所有提交的新代码,我希望我的开发人员能够进行100%的代码覆盖。但问题是他们不能为UI相关的更改编写测试。我在网上看到Selenium是用户界面测试的解决方案之一。

Can anyone share me a link to blog or tutorial which teaches me how to set up Selenium or some other automated UI testing for Rails. The version I use is 2.3.8.

任何人都可以与我分享博客或教程的链接,它教我如何为Rails设置Selenium或其他一些自动UI测试。我使用的版本是2.3.8。

1 个解决方案

#1


3  

Checkout the two mainstream Acceptance testing frameworks:

查看两个主流验收测试框架:

  • Cucumber
  • Steak (minimalist approach)
  • 牛排(极简主义方法)

Best place to start (in my opinion): Railscasts. Try the beginning with cucumber railscast.

最好的起点(在我看来):Railscasts。尝试从黄瓜railscast开始。

Your "code" will end up looking like

你的“代码”最终会像

Feature: pay bill on-line
  In order to reduce the time I spend paying bills
  As a bank customer with a checking account
  I want to pay my bills on-line

  Scenario: pay a bill
    Given checking account with $50
    And a payee named Acme
    And an Acme bill for $37
    When I pay the Acme bill
    Then I should have $13 remaining in my checking account
    And the payment of $37 to Acme should be listed in Recent Payments

Code found on http://iain.nl/2011/01/cucumber-vs-steak/

代码见http://iain.nl/2011/01/cucumber-vs-steak/

#1


3  

Checkout the two mainstream Acceptance testing frameworks:

查看两个主流验收测试框架:

  • Cucumber
  • Steak (minimalist approach)
  • 牛排(极简主义方法)

Best place to start (in my opinion): Railscasts. Try the beginning with cucumber railscast.

最好的起点(在我看来):Railscasts。尝试从黄瓜railscast开始。

Your "code" will end up looking like

你的“代码”最终会像

Feature: pay bill on-line
  In order to reduce the time I spend paying bills
  As a bank customer with a checking account
  I want to pay my bills on-line

  Scenario: pay a bill
    Given checking account with $50
    And a payee named Acme
    And an Acme bill for $37
    When I pay the Acme bill
    Then I should have $13 remaining in my checking account
    And the payment of $37 to Acme should be listed in Recent Payments

Code found on http://iain.nl/2011/01/cucumber-vs-steak/

代码见http://iain.nl/2011/01/cucumber-vs-steak/