在 Ruby on Rails 开发中使用 Cucumber 传递 autospec 中的选项

发布于 2024-08-17 17:45:11 字数 812 浏览 4 评论 0原文

我总是运行 autospec 来同时运行功能和 RSpec,但在本地计算机上运行所有功能通常非常耗时。我会在提交代码之前运行每个功能。

我想在 autospec 命令中传递参数。 autospec 显然不直接接受参数。这是 autospec -h 的输出:

    autotest [options]

options:
    -h
    -help       You're looking at it.

    -v      Be verbose.
            Prints files that autotest doesn't know how to map to
            tests.

    -q      Be more quiet.

    -f      Fast start.
            Doesn't initially run tests at start.

我在 config 目录中有一个 cucumber.yml 。我的 Rails 根目录中还有 rerun.txtcucumber -h 为我提供了大量有关参数的信息。

如何针对标记为 @wip 的功能运行 autospec?我想我可以利用config/cucumber.yml。有配置文件定义。我可以运行 cucumber -p wip 来仅运行 @wip 标记的功能,但我想使用 autospec 来执行此操作。

我将不胜感激任何有关使用许多规范和功能文件的提示。

I always run autospec to run features and RSpec at the same time, but running all the features is often time-consuming on my local computer. I would run every feature before committing code.

I would like to pass the argument in autospec command. autospec doesn't obviously doesn't accept the arguments directly. Here's the output of autospec -h:

    autotest [options]

options:
    -h
    -help       You're looking at it.

    -v      Be verbose.
            Prints files that autotest doesn't know how to map to
            tests.

    -q      Be more quiet.

    -f      Fast start.
            Doesn't initially run tests at start.

I do have a cucumber.yml in config directory. I also have rerun.txt in the Rails root directory. cucumber -h gives me a lot of information about arguments.

How can I run autospec against features that are tagged as @wip? I think I can make use of config/cucumber.yml. There are profile definitions. I can run cucumber -p wip to run only @wip-tagged features, but I'd like to do this with autospec.

I would appreciate any tips for working with many spec and feature files.

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

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

发布评论

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

评论(4

与他有关 2024-08-24 17:45:11

如果您使用的是 OSX,则可以尝试使用 Kicker gem 在文件更改时启动 Cucumber:

$ kicker -e "cucumber -p wip" .

不幸的是,我不知道是否有类似的程序可以在 windows/linux 上进行任意文件监视

If you're on OSX, you can try using the Kicker gem to launch cucumber when files change:

$ kicker -e "cucumber -p wip" .

Unfortunately, I don't know if there's a comparable program to do arbitrary file watches on windows/linux

不知所踪 2024-08-24 17:45:11

如果您的 cucumber.yml 文件中有 autotest 配置文件,autospec 将使用该配置文件而不是默认配置文件。

我正在使用类似的东西来运行 @wip 任务:

autotest: --format pretty --tags @wip:3 --wip features

这基本上是说:“运行用 @wip 标记的前三个场景”。

如果您希望在运行整个套件时(通常在红色 => 绿色转换之后)有与 autospec 不同的行为,您还可以添加 autotest-all 配置文件。这是一个帮助您入门的粗略示例:

autotest-all: --require features --format pretty

If you have an autotest profile in your cucumber.yml file, autospec will use that one instead of the default profile.

I'm using something like this to run @wip tasks:

autotest: --format pretty --tags @wip:3 --wip features

This basically says: "run first three scenarios tagged with @wip".

You could also add an autotest-all profile, if you want a different behavior from autospec when running the entire suite (normally after a red => green transition). Here's a rough example to get you started:

autotest-all: --require features --format pretty
月依秋水 2024-08-24 17:45:11

好吧,一个技巧是,您可以通过将 AUTOFEATURE 设置为 false 来运行规范而不运行功能:

export AUTOFEATURE=false

这样您就可以运行规范,直到它们全部变为绿色,然后将 AUTOFEATURE 设置回 true 并让您的功能运行,当它们全部通过时你可以开始重构。

Well, one tip is that you can run specs without running features, by setting AUTOFEATURE to false:

export AUTOFEATURE=false

That way you can run your specs until they are all green, then set AUTOFEATURE back to true and get your features running, and when they all pass you can get to refactoring.

他不在意 2024-08-24 17:45:11

我不使用自动测试或自动规范来运行功能,而是定期手动运行它们。 Cucumber 功能不像 rspec 测试那么智能,并且会针对最小的更改运行。 TDD 固然很好,但它应该加快速度,而不是减慢速度。

因此,我运行:

./spec/autospec

在一个窗口中,并且

cucumber --tags @wip

I do not run features with autotest or autospec, but instead run them manually periodically. Cucumber features are not as smart as rspec tests and will run for the smallest change. TDD is all well and good, but it's supposed to speed things up, not slow them down.

Thus, I run:

./spec/autospec

in one window, and

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