有没有好的开源 BDD 工具用于 C/C++?

发布于 2024-07-06 17:07:18 字数 1560 浏览 6 评论 0原文

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

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

发布评论

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

评论(6

绝情姑娘 2024-07-13 17:07:19

看来您可以使用 Ruby 和 RSpec 使用 swig 生成包装器来测试您的 C 代码! 请参阅 Ben Mabey 的帖子:
http://benmabey.com/2007/09/09/bdd- your-c.html

我已经尝试过这个例子,它对我有用。 我不确定是否有人进一步采取行动。

It seems you can test your C code using Ruby and RSpec using swig to generate wrappers! See Ben Mabey's post here:
http://benmabey.com/2007/09/09/bdd-your-c.html

I've tried that example out and it worked for me. I'm not sure if anyone has taken it any further.

ゞ记忆︶ㄣ 2024-07-13 17:07:19

原始链接 (CppSpec) 已失效,但仍可在 互联网档案,位于 CppSpec

正如 @VickyChijwani 已经提到的,该项目的副本位于 Github - tpuronen/cppspec

The original link (CppSpec) is dead, but it is still accessible at the Internet Archive at CppSpec.

And as @VickyChijwani already mentioned, there's a copy of the project at Github - tpuronen/cppspec

明月松间行 2024-07-13 17:07:19

Igloo 是我期待尝试的一个

Igloo is one I'm looking forward to try some time

凉城已无爱 2024-07-13 17:07:19

由于需要一个类似 RSpec 的框架,我想添加最近的 igloo
虽然最初针对的是Context/Spec语法,但它也支持Describe/It语法。 像那些基于 C 的框架一样,设置测试运行器和测试装置并没有太多噪音。 甚至感觉比 CppSpec 更好看。 他们通过使用合适的模板机制来实现这一点。

Since an RSpec like framework was requested, I'd like to add the recent igloo.
Though originally aiming at Context/Spec syntax, it also supports Describe/It syntax. There isn't much noise in setting the test runner and test fixtures up like in those C-based frameworks. It even feels better to look at than CppSpec. They achieve this through use of decent templating mechanics.

屌丝范 2024-07-13 17:07:19

尝试 CBehave! 它是一个类似 RSpec 的 BDD 框架,使用给定/何时/然后宏。 例子:

FEATURE(1, "strstr")
    SCENARIO("The strstr finds the first occurrence of the substring in the source string")

       GIVEN("A source string: [Lionel Messi is a great football player]")
           char *str = "Lionel Messi is a great football player";
       GIVEN_END

       WHEN("we use strstr to find the first occurrence of [football]")
           char *p = strstr(str, "football");
       WHEN_END

       THEN("We should get the string: [football player]")
           SHOULD_STR_EQUAL(p, "football player");
       THEN_END
   SCENARIO_END
FEATURE_END

Try CBehave! It is an RSpec-like BDD framework that uses given/when/then macros. Example:

FEATURE(1, "strstr")
    SCENARIO("The strstr finds the first occurrence of the substring in the source string")

       GIVEN("A source string: [Lionel Messi is a great football player]")
           char *str = "Lionel Messi is a great football player";
       GIVEN_END

       WHEN("we use strstr to find the first occurrence of [football]")
           char *p = strstr(str, "football");
       WHEN_END

       THEN("We should get the string: [football player]")
           SHOULD_STR_EQUAL(p, "football player");
       THEN_END
   SCENARIO_END
FEATURE_END
花海 2024-07-13 17:07:18

cspec 适用于 C。大概它可以与 C++ 一起使用。 行为驱动开发维基百科页面上有适用于各种语言的工具列表。

cspec is for C. Presumably it will work with C++. There is a list of tools for various languages on the Behavior Driven Development Wikipedia page.

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