我喜欢Ruby RSpec BDD开发风格。使用C / C ++有没有好的工具?

有帮助吗?

解决方案

cspec 适用于C.据推测它适用于C ++。 行为驱动开发维基百科页面上列出了各种语言的工具。

其他提示

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

我已经尝试了这个例子,它对我有用。我不确定是否有人更进一步。

原始链接( CppSpec )已经死亡,但仍然可以访问< a href =“https://archive.org/web/”rel =“nofollow noreferrer”> Internet Archive CppSpec

正如@VickyChijwani已经提到的那样, Github - tpuronen / cppspec 上有一个项目的副本

Igloo 是我期待尝试的时间

由于要求提供类似RSpec的框架,我想添加最近的 igloo 。 虽然最初的目标是Context / Spec语法,但它也支持Describe / It语法。在基于C的框架中设置测试运行器和测试夹具没有太大的噪音。看起来比CppSpec更好看。他们通过使用体面的模板机制来实现这一目标。

尝试 CBehave !它是一个类似RSpec的BDD框架,它使用given / when / then宏。例如:

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top