用于 PHP 应用程序的 Cucumber

发布于 2024-08-04 06:17:37 字数 176 浏览 1 评论 0原文

是否可以在 Rails 之外使用 Cucumber?我想开始使用它来测试我的一些 PHP 应用程序,但我真的不知道如何开始。

也许最简单的方法是创建一个仅运行 Cucumber 功能的 Rails 项目,但在我看来这有点矫枉过正。

设置 Cucumber 来测试非 Rails 应用程序的最简单方法是什么?

Is it possible to use Cucumber outside Rails? I'd like to start using it for testing some of my PHP applications, but I really don't know how to start.

Probably the easiest way would be creating a Rails project only to run Cucumber features, but that seems like to me as overkill.

What is the simplest way to set up Cucumber for testing a non-Rails application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

孤凫 2024-08-11 06:17:37

查看:

https://github.com/cucumber/cucumber/wiki/php

很容易用PHP使用cucumber,甚至管理数据库。

Check out:

https://github.com/cucumber/cucumber/wiki/php

It is easy to use cucumber with PHP, even managing the database.

┾廆蒐ゝ 2024-08-11 06:17:37

查看 http://everzet.com/Behat/
(URL 似乎已更改为 http://behat.org/

Checkout http://everzet.com/Behat/
(the URL appears to have changed to http://behat.org/)

浪荡不羁 2024-08-11 06:17:37

引自 cucumber 网站:

Cucumber 可与 Ruby、Java、.NET、Flex 或以任何语言编写的 Web 应用程序配合使用。它已被翻译成 30 多种语言。

Cited from the cucumber website:

Cucumber works with Ruby, Java, .NET, Flex or web applications written in any language. It has been translated to over 30 spoken languages.

暖心男生 2024-08-11 06:17:37

这是如何使用 Cucumber 对 PHP Web 应用程序进行功能测试的一个很好的示例...它将向您展示如何设置测试文件夹以及在何处放置步骤
http://jystewart.net/2008/11/ 10/testing-php-apps-with-ruby-tools/

看看这个家伙用 Capybara 做了什么。
Capbyara 是一个让您选择 CLI 浏览器驱动程序的软件包 - 基本上您可以使用 @javascript 进行测试,并且场景将使用 Selenium 非常强大的 chrome 进行播放...这使您可以在需要时顺利测试 javascript!
http://otaqui.com/blog/1072/testing-remote-php-websites-with-capybara-cucumber-mechanize-selenium-2-webdriver-and-saucelabs/

此外,我一直在查看在这个链接中,作者使用 Cuke4PHP 将 PHPUnit 与 Cucumber 集成...然后您可以将 PHPUnit 测试包装在 CucumberSteps 中...允许您使用现有的 PHP 代码对应用程序和数据库进行行为测试
http://lucato.it/php-bdd-cucumber-cuke4php

我自己正在尝试将所有这些部分融合在一起,首先成为一个可用的、然后是强大的测试平台,用于现有的重型 PHP Web 应用程序……但我才刚刚开始。如果我取得了良好的进展,我会向您更新。

Here's a great example of how to functionally test a PHP Webapp using Cucumber ... it will show you how to set up your test folder and where to put steps
http://jystewart.net/2008/11/10/testing-php-apps-with-ruby-tools/

Check out what this guy has done with Capybara.
Capbyara is a package that lets you choose your CLI browser driver - basically you can preface tests with @javascript and the Scenario will be played out using Selenium's very powerful chrome ... this allows you to smoothly test javascript where required!!!
http://otaqui.com/blog/1072/testing-remote-php-websites-with-capybara-cucumber-mechanize-selenium-2-webdriver-and-saucelabs/

Further, I've been checking out this link, where the author uses Cuke4PHP to integrate PHPUnit with Cucumber ... this would then let you wrap PHPUnit tests in CucumberSteps ... allowing you to behaviorally test your application and DB using your existing PHP code
http://lucato.it/php-bdd-cucumber-cuke4php

I myself am trying to meld all these pieces together into first a working and then robust test platform for a heavy-duty existing PHP webapp ... but I just began. Will update you if I make a good progress.

安静被遗忘 2024-08-11 06:17:37

你绝对可以看看 Behat水貂。 Behat 是 Cucumber 的 Gherkin 语法(Given、When、Thens)的运行程序,Mink 让 Behat 运行真正的浏览器。它为您提供跨多个浏览器驱动程序的单一 API,与 Ruby 的 Capybara 非常相似。

虽然使用 Cucumber 和 Webrat 或 Selenium 之类的东西来测试非 Ruby 应用程序是可以的,但如果您的应用程序是这样编写的,那么坚持使用 PHP 有很多好处 - 开发人员技能和应用程序设置的简便性(您在给定步骤中执行的操作)是最明显的。

You could definitely look at Behat and Mink. Behat is a runner for cucumber's Gherkin syntax (Given, When, Thens) and Mink lets Behat run real browsers. It provides you with a single API across several browser drivers, quite similar to Ruby's Capybara.

While using Cucumber and something like Webrat or Selenium to test a non Ruby application is ok, sticking with PHP if that's what your app is written has manifold benefits - developer skillset and ease of app setup (the kind of stuff you do in Given steps) being the most obvious.

奶茶白久 2024-08-11 06:17:37

Behat 带有 MinkPhantomJSSahi 扩展,是一个很棒的 php BDD 组合。无论如何,如果你是从 QA 的角度来看的话。

Behat, with Mink, PhantomJS and Sahi extensions, is a great BDD combo for php. If you are coming at it from a QA perspective, anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文