如何定位特定的 Calabash 功能文件?

How to target specific Calabash feature files?

我一直在寻找这个答案,但我现在还没弄明白。

假设我有一个测试环境和一个生产环境。我创建了葫芦场景,无论我是 运行 进行测试还是生产,这些场景都需要有所不同。我所有的场景都写在/feature/xxx.feature

问题是,当我 运行 测试时,所有 *.feature 都将是 运行。因此,我创建了一个环境变量,根据我想要 运行 测试的环境进行更改。

如何定位正确的 .feature 文件?如何告诉Calabash:当环境变量设置为"production"时请只运行 /feature/prodution/.feature 个文件?*

非常感谢您的帮助!

这真是一道黄瓜题

我推荐使用标签。以下示例适用于 iOS,但原则适用于 Android。

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

您可以在Calabash iOS Smoke Test App.

中看到我们如何使用标签
# Run the animation tests
$ bundle exec cucumber -t @animations

# Run the backdoor tests
$ bundle exec cucumber -t @backdoor

您可以将标签与 Cucumber 配置文件结合使用以获得更高级的行为。

 # Run the backdoor tests in the production environment
 $ bundle exec -p production -t @backdoor

您可以使用此命令定位特定功能。

bundler exec calabash-android run <apk>.apk <feature folder>/<feature name to execute>.feature

例如:

bundler exec calabash-android run <apk>.apk feature/Home.feature

您也可以使用带有功能的标签

bundler exec calabash-android run <apk>.apk <feature folder>/<feature to execure>.feature --tags @<tag name>

例如:

bundler exec calabash-android run <apk>.apk feature/Home.feature --tags @test

假设您有 homepage.feature 并且想要 运行 整个功能文件

运行 整个特征文件:calabash-android 运行 apkname.apk features/homepage.feature

运行 特定测试:calabash-android 运行 apkname.apk features/homepage.feature --tags @smoke