Frank:是否可以用 Objective-C 编写步骤定义

发布于 2024-10-21 07:21:58 字数 756 浏览 2 评论 0原文

  1. 如何在 Objective-C 中编写步骤定义?例如:

    Given(@"^通讯录为空$", ^{
        ABAddressBookRef 地址簿 = ABAddressBookCreate();
        CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
        for (int i = 0; i < CFArrayGetCount(people); i++) {
            ABAddressBookRemoveRecord(addressBook,
                    CFArrayGetValueAtIndex(people, i), NULL);
        }
    });
    

    上面的示例源自 Rob Holland 的博客文章“BDD on iPhone” :iCuke”

    我为什么要做这样的事情?因为,尽管我很喜欢 Ruby,但我更喜欢用 Objective-C 开发 iOS 应用程序,并使用与我正在测试的应用程序相同的语言编写测试。此外,这还允许我做一些低级的事情,比如擦除地址簿或使用 Core Data 编辑其他数据。

  2. 我可以用大写“F”将features目录命名为Features吗?

  1. How could I write step definitions in Objective-C? E.g.:

    Given(@"^the address book is empty$", ^{
        ABAddressBookRef addressBook = ABAddressBookCreate();
        CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
        for (int i = 0; i < CFArrayGetCount(people); i++) {
            ABAddressBookRemoveRecord(addressBook,
                    CFArrayGetValueAtIndex(people, i), NULL);
        }
    });
    

    The example above was derived from Rob Holland's blog post "BDD on iPhone: iCuke".

    Why would I want to do such a thing? Because, as much as I love Ruby, I prefer to develop iOS apps in Objective-C and to write tests in the same language as that of the app I'm testing. Also, this would allow me to do low-level things, like erasing the address book or editing other data with Core Data.

  2. Can I name the features directory Features with a capital "F"?

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

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

发布评论

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

评论(3

堇年纸鸢 2024-10-28 07:21:58

我在此处回复了 Frank 邮件列表中 Matt 的问题

I responded to Matt's question on the Frank mailing list here

穿越时光隧道 2024-10-28 07:21:58

我同意;在 Objective-C 中测试您的 Objective-C 应用程序。就我个人而言,我使用 Cedar 来完成此任务,并且会在 Objective-C 中彻底完成(无 cuke),但我意识到这可能不是一个非常有用的答案。不是要劫持你的帖子,但你是否发现 Frank 比 Cedar 更容易设置?

I agree; test your Objective-C applications in Objective-C. Personally, I use Cedar for this and would do it soup-to-nuts in Objective-C (no cuke), but I realize that might not be a very helpful answer. Not to hijack your thread, but did you find Frank to be any easier than Cedar to set up?

π浅易 2024-10-28 07:21:58

尝试回答你的第二个问题:

默认情况下,我认为 Cucumber 会寻找“features”目录。我不知道它是否区分大小写,但事实上您的询问意味着它可能是区分大小写的。您可以在运行 Cucumber 时指定目录。

例如。我的 Rakefile 中具有非标准位置的黄瓜目标

Cucumber::Rake::Task.new do |t|
  t.cucumber_opts = ["--format pretty", "FunctionalTests/Frank"]
end

To attempt to answer your second question:

By default I think Cucumber looks for a 'features' directory. I don't know if it is case sensitive, but the fact that your asking means it probably is. You can specify the directory when you run Cucumber.

eg. a cucumber target in my Rakefile with non-standard location

Cucumber::Rake::Task.new do |t|
  t.cucumber_opts = ["--format pretty", "FunctionalTests/Frank"]
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文